Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui/embark-anywhere] auto-dismiss screen after confirm #950

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions gui/embark-anywhere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ end
function EmbarkAnywhereScreen:init()
self:addviews{
EmbarkAnywhere{view_id='main'},
-- this panel will get checked for masking too, but it's wholely
-- inside the size selection panel, so it's ok
widgets.Panel{
frame={l=20, t=1, w=22, h=6},
frame_style=gui.FRAME_MEDIUM,
Expand All @@ -58,17 +56,23 @@ function EmbarkAnywhereScreen:init()
},
visible=is_confirm_panel_visible,
},
widgets.Panel{ -- size selection panel
frame={l=0, t=0, w=61, h=11},
},
widgets.Panel{ -- abort button
frame={r=41, b=1, w=10, h=3},
},
widgets.Panel{ -- show elevation button
frame={r=22, b=1, w=18, h=3},
},
widgets.Panel{ -- show cliffs button
frame={r=0, b=1, w=21, h=3},
widgets.Panel{
view_id='masks',
frame={t=0, b=0, l=0, r=0},
subviews={
widgets.Panel{ -- size selection panel
frame={l=0, t=0, w=61, h=11},
},
widgets.Panel{ -- abort button
frame={r=41, b=1, w=10, h=3},
},
widgets.Panel{ -- show elevation button
frame={r=22, b=1, w=18, h=3},
},
widgets.Panel{ -- show cliffs button
frame={r=0, b=1, w=21, h=3},
},
},
},
}
end
Expand All @@ -91,10 +95,8 @@ local function force_embark(scr)
end

function EmbarkAnywhereScreen:clicked_on_panel_mask()
for _, sv in ipairs(self.subviews) do
if sv.view_id ~= 'main' then
if sv:getMousePos() then return true end
end
for _, sv in ipairs(self.subviews.masks.subviews) do
if sv:getMousePos() then return true end
end
end

Expand All @@ -116,6 +118,14 @@ function EmbarkAnywhereScreen:onDismiss()
view = nil
end

function EmbarkAnywhereScreen:onRenderFrame(dc, rect)
local scr = dfhack.gui.getDFViewscreen(true)
if not dfhack.gui.matchFocusString('choose_start_site', scr) then
self:dismiss()
end
EmbarkAnywhereScreen.super.onRenderFrame(self, dc, rect)
end

if not dfhack.gui.matchFocusString('choose_start_site') then
qerror('This script can only be run when choosing an embark site')
end
Expand Down