101 lines
2.7 KiB
Lua
101 lines
2.7 KiB
Lua
-- AutoMark debug HUD element: plain-text live status panel (fork feature).
|
|
-- Instantiated by the game HUD pipeline (UIHud._add_element requires this file
|
|
-- by definition.filename). Content is produced by AutoMark mod side
|
|
-- (ui/debug_hud.lua -> mod.debug_hud_last) so this file stays dumb.
|
|
local UIWorkspaceSettings = require("scripts/settings/ui/ui_workspace_settings")
|
|
local UIWidget = require("scripts/managers/ui/ui_widget")
|
|
|
|
require("scripts/foundation/utilities/color")
|
|
|
|
local mod = get_mod("AutoMark")
|
|
|
|
local HudElementAutoMarkDebug = class("HudElementAutoMarkDebug", "HudElementBase")
|
|
|
|
local panel_size = { 860, 800 }
|
|
|
|
local scenegraph_definition = {
|
|
screen = UIWorkspaceSettings.screen,
|
|
panel = {
|
|
horizontal_alignment = "left",
|
|
parent = "screen",
|
|
vertical_alignment = "middle",
|
|
size = panel_size,
|
|
position = {
|
|
25,
|
|
0,
|
|
10,
|
|
},
|
|
},
|
|
}
|
|
|
|
local widget_definitions = {
|
|
automark_debug = UIWidget.create_definition({
|
|
{
|
|
pass_type = "text",
|
|
style_id = "debug_text",
|
|
value_id = "debug_text",
|
|
style = {
|
|
drop_shadow = true,
|
|
font_size = 19,
|
|
font_type = "proxima_nova_bold",
|
|
horizontal_alignment = "left",
|
|
vertical_alignment = "top",
|
|
text_horizontal_alignment = "left",
|
|
text_vertical_alignment = "top",
|
|
line_spacing = 1.2,
|
|
size = panel_size,
|
|
offset = {
|
|
0,
|
|
0,
|
|
0,
|
|
},
|
|
text_color = Color.terminal_text_header(255, true),
|
|
},
|
|
},
|
|
}, "panel"),
|
|
}
|
|
|
|
HudElementAutoMarkDebug.init = function (self, parent, draw_layer, start_scale)
|
|
HudElementAutoMarkDebug.super.init(self, parent, draw_layer, start_scale, {
|
|
scenegraph_definition = scenegraph_definition,
|
|
widget_definitions = widget_definitions,
|
|
})
|
|
self._rebuild_time = 0
|
|
self._last_text = nil
|
|
end
|
|
|
|
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
|
|
if self._rebuild_time > 0 then
|
|
return
|
|
end
|
|
self._rebuild_time = 0.2
|
|
|
|
local panel = self._ui_scenegraph and self._ui_scenegraph.panel
|
|
if panel and panel.local_position then
|
|
local lp = panel.local_position
|
|
local x = mod.settings.debug_hud_x or 25
|
|
local y = mod.settings.debug_hud_y or 0
|
|
if lp[1] ~= x or lp[2] ~= y then
|
|
lp[1] = x
|
|
lp[2] = y
|
|
end
|
|
end
|
|
|
|
local buf = mod.debug_hud_last
|
|
local text = table.concat(buf, "\n")
|
|
|
|
if text ~= self._last_text then
|
|
self._last_text = text
|
|
local widget = self._widgets_by_name.automark_debug
|
|
if widget then
|
|
widget.content.debug_text = text
|
|
widget.dirty = true
|
|
end
|
|
end
|
|
end
|
|
|
|
return HudElementAutoMarkDebug
|