fix: debug HUD never injected — mod files are invisible to the game require system (DMF loads via own file loader); registered element with mod:add_require_path and moved injection to UIHud:init hook following NumericUI's proven pattern (+ inject evidence line, super.update call, Color fn for text)
This commit is contained in:
@@ -9,9 +9,15 @@ local ScriptUnit_extension = ScriptUnit.extension
|
|||||||
mod.debug_hud_last = {}
|
mod.debug_hud_last = {}
|
||||||
|
|
||||||
local ELEMENT_CLASS_NAME = "HudElementAutoMarkDebug"
|
local ELEMENT_CLASS_NAME = "HudElementAutoMarkDebug"
|
||||||
|
local ELEMENT_FILENAME = "AutoMark/scripts/mods/AutoMark/ui/hud_element_debug"
|
||||||
|
|
||||||
mod:hook(CLASS.UIManager, "create_player_hud",
|
-- the game HUD requires element files through the game require system; without
|
||||||
function(func, self, peer_id, local_player_id, elements, visibility_groups)
|
-- registering here, require(ELEMENT_FILENAME) from UIHud._add_element never finds
|
||||||
|
-- the mod file (DMF loads mod scripts through its own file loader, not package.path)
|
||||||
|
mod:add_require_path(ELEMENT_FILENAME)
|
||||||
|
|
||||||
|
mod:hook("UIHud", "init",
|
||||||
|
function(func, self, elements, visibility_groups, params)
|
||||||
if mod_settings.debug_hud and elements then
|
if mod_settings.debug_hud and elements then
|
||||||
local already = false
|
local already = false
|
||||||
for i = 1, #elements do
|
for i = 1, #elements do
|
||||||
@@ -23,13 +29,20 @@ mod:hook(CLASS.UIManager, "create_player_hud",
|
|||||||
if not already then
|
if not already then
|
||||||
elements[#elements + 1] = {
|
elements[#elements + 1] = {
|
||||||
class_name = ELEMENT_CLASS_NAME,
|
class_name = ELEMENT_CLASS_NAME,
|
||||||
filename = "AutoMark/scripts/mods/AutoMark/ui/hud_element_debug",
|
filename = ELEMENT_FILENAME,
|
||||||
use_hud_scale = true,
|
use_hud_scale = true,
|
||||||
visibility_groups = { "alive", "dead" },
|
visibility_groups = { "alive", "dead" },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
if not mod.debug_hud_inject_logged then
|
||||||
|
mod.debug_hud_inject_logged = true
|
||||||
|
mod:diag("OMNI-HUD inject: setting=on already=", tostring(already))
|
||||||
|
end
|
||||||
|
elseif not mod.debug_hud_inject_logged then
|
||||||
|
mod.debug_hud_inject_logged = true
|
||||||
|
mod:diag("OMNI-HUD inject: setting=off, skipped")
|
||||||
end
|
end
|
||||||
return func(self, peer_id, local_player_id, elements, visibility_groups)
|
return func(self, elements, visibility_groups, params)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function unit_breed_name(unit)
|
local function unit_breed_name(unit)
|
||||||
|
|||||||
@@ -49,12 +49,7 @@ local widget_definitions = {
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
text_color = {
|
text_color = Color.terminal_text_header(255, true),
|
||||||
240,
|
|
||||||
235,
|
|
||||||
180,
|
|
||||||
255,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, "panel"),
|
}, "panel"),
|
||||||
@@ -70,6 +65,8 @@ HudElementAutoMarkDebug.init = function (self, parent, draw_layer, start_scale)
|
|||||||
end
|
end
|
||||||
|
|
||||||
HudElementAutoMarkDebug.update = function (self, dt, t, ui_renderer, render_settings, input_service)
|
HudElementAutoMarkDebug.update = function (self, dt, t, ui_renderer, render_settings, input_service)
|
||||||
|
HudElementAutoMarkDebug.super.update(self, dt, t, ui_renderer, render_settings, input_service)
|
||||||
|
|
||||||
self._rebuild_time = self._rebuild_time - dt
|
self._rebuild_time = self._rebuild_time - dt
|
||||||
if self._rebuild_time > 0 then
|
if self._rebuild_time > 0 then
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user