fix logo disappearing when hovered on title screen

develop
Myk Taylor 2023-04-30 16:40:03 -07:00
parent 923f84b2f2
commit 0d6c5869f4
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 16 additions and 13 deletions

@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins ## New Plugins
## Fixes ## Fixes
- `hotkeys`: DFHack logo no longer disappears when hovered on the title screen
## Misc Improvements ## Misc Improvements

@ -447,7 +447,7 @@ function update_hotspot_widgets()
end end
end end
local function matches_focus_strings(db_entry, vs_name) local function matches_focus_strings(db_entry, vs_name, vs)
if not db_entry.focus_strings then return true end if not db_entry.focus_strings then return true end
local matched = true local matched = true
local simple_vs_name = simplify_viewscreen_name(vs_name) local simple_vs_name = simplify_viewscreen_name(vs_name)
@ -465,9 +465,10 @@ end
local function _update_viewscreen_widgets(vs_name, vs, now_ms) local function _update_viewscreen_widgets(vs_name, vs, now_ms)
local vs_widgets = active_viewscreen_widgets[vs_name] local vs_widgets = active_viewscreen_widgets[vs_name]
if not vs_widgets then return end if not vs_widgets then return end
local is_all = vs_name == 'all'
now_ms = now_ms or dfhack.getTickCount() now_ms = now_ms or dfhack.getTickCount()
for name,db_entry in pairs(vs_widgets) do for name,db_entry in pairs(vs_widgets) do
if matches_focus_strings(db_entry, vs_name) and if (is_all or matches_focus_strings(db_entry, vs_name, vs)) and
do_update(name, db_entry, now_ms, vs) then do_update(name, db_entry, now_ms, vs) then
return return
end end
@ -483,12 +484,12 @@ function update_viewscreen_widgets(vs_name, vs)
end end
end end
local function _feed_viewscreen_widgets(vs_name, keys) local function _feed_viewscreen_widgets(vs_name, vs, keys)
local vs_widgets = active_viewscreen_widgets[vs_name] local vs_widgets = active_viewscreen_widgets[vs_name]
if not vs_widgets then return false end if not vs_widgets then return false end
for _,db_entry in pairs(vs_widgets) do for _,db_entry in pairs(vs_widgets) do
local w = db_entry.widget local w = db_entry.widget
if matches_focus_strings(db_entry, vs_name) and if (not vs or matches_focus_strings(db_entry, vs_name, vs)) and
detect_frame_change(w, function() return w:onInput(keys) end) then detect_frame_change(w, function() return w:onInput(keys) end) then
return true return true
end end
@ -496,9 +497,9 @@ local function _feed_viewscreen_widgets(vs_name, keys)
return false return false
end end
function feed_viewscreen_widgets(vs_name, keys) function feed_viewscreen_widgets(vs_name, vs, keys)
if not _feed_viewscreen_widgets(vs_name, keys) and if not _feed_viewscreen_widgets(vs_name, vs, keys) and
not _feed_viewscreen_widgets('all', keys) then not _feed_viewscreen_widgets('all', nil, keys) then
return false return false
end end
gui.markMouseClicksHandled(keys) gui.markMouseClicksHandled(keys)
@ -508,13 +509,13 @@ function feed_viewscreen_widgets(vs_name, keys)
return true return true
end end
local function _render_viewscreen_widgets(vs_name, dc) local function _render_viewscreen_widgets(vs_name, vs, dc)
local vs_widgets = active_viewscreen_widgets[vs_name] local vs_widgets = active_viewscreen_widgets[vs_name]
if not vs_widgets then return end if not vs_widgets then return end
dc = dc or gui.Painter.new() dc = dc or gui.Painter.new()
for _,db_entry in pairs(vs_widgets) do for _,db_entry in pairs(vs_widgets) do
local w = db_entry.widget local w = db_entry.widget
if matches_focus_strings(db_entry, vs_name) then if not vs or matches_focus_strings(db_entry, vs_name, vs) then
detect_frame_change(w, function() w:render(dc) end) detect_frame_change(w, function() w:render(dc) end)
end end
end end
@ -523,9 +524,9 @@ end
local force_refresh local force_refresh
function render_viewscreen_widgets(vs_name) function render_viewscreen_widgets(vs_name, vs)
local dc = _render_viewscreen_widgets(vs_name, nil) local dc = _render_viewscreen_widgets(vs_name, vs, nil)
_render_viewscreen_widgets('all', dc) _render_viewscreen_widgets('all', nil, dc)
if force_refresh then if force_refresh then
force_refresh = nil force_refresh = nil
df.global.gps.force_full_display_count = 1 df.global.gps.force_full_display_count = 1

@ -72,9 +72,10 @@ struct viewscreen_overlay : T {
bool input_is_handled = false; bool input_is_handled = false;
// don't send input to the overlays if there is a modal dialog up // don't send input to the overlays if there is a modal dialog up
if (!world->status.popups.size()) if (!world->status.popups.size())
call_overlay_lua(NULL, "feed_viewscreen_widgets", 2, 1, call_overlay_lua(NULL, "feed_viewscreen_widgets", 3, 1,
[&](lua_State *L) { [&](lua_State *L) {
Lua::Push(L, T::_identity.getName()); Lua::Push(L, T::_identity.getName());
Lua::Push(L, this);
Lua::PushInterfaceKeys(L, *input); Lua::PushInterfaceKeys(L, *input);
}, [&](lua_State *L) { }, [&](lua_State *L) {
input_is_handled = lua_toboolean(L, -1); input_is_handled = lua_toboolean(L, -1);