From 2f2dae785da27ec8d3ccea19a3347a2f30aad706 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Jun 2024 19:13:59 -0700 Subject: [PATCH 1/2] don't let the "assume control of unit" button it crashes the game --- gui/sandbox.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gui/sandbox.lua b/gui/sandbox.lua index 78b078533d..33cd589c84 100644 --- a/gui/sandbox.lua +++ b/gui/sandbox.lua @@ -214,7 +214,20 @@ function Sandbox:onInput(keys) return true end if keys._MOUSE_L then - if self:getMouseFramePos() then return true end + -- don't click "through" the gui/sandbox ui + if self:getMouseFramePos() then + return true + end + -- don't allow clicking on the "assume control" button of a unit + local scr = dfhack.gui.getDFViewscreen(true) + if dfhack.gui.matchFocusString('dwarfmode/ViewSheets/UNIT/Overview', scr) then + local interface_rect = gui.ViewRect{rect=gui.get_interface_rect()} + local button_rect = interface_rect:viewport(60, 50, 20, 3) + local mouse_x, mouse_y = dfhack.screen.getMousePos() + if mouse_x and button_rect:inClipGlobalXY(mouse_x, mouse_y) then + return true + end + end for _,mask_panel in ipairs(self.interface_masks) do if mask_panel:getMousePos() then return true end end From 4d287d360f91abc9d50e7573e4f5c1dcc5713994 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 24 Jun 2024 19:23:10 -0700 Subject: [PATCH 2/2] measure from correct screen edge --- gui/sandbox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/sandbox.lua b/gui/sandbox.lua index 33cd589c84..e99e3d3a64 100644 --- a/gui/sandbox.lua +++ b/gui/sandbox.lua @@ -222,7 +222,7 @@ function Sandbox:onInput(keys) local scr = dfhack.gui.getDFViewscreen(true) if dfhack.gui.matchFocusString('dwarfmode/ViewSheets/UNIT/Overview', scr) then local interface_rect = gui.ViewRect{rect=gui.get_interface_rect()} - local button_rect = interface_rect:viewport(60, 50, 20, 3) + local button_rect = interface_rect:viewport(interface_rect.width-77, interface_rect.height-7, 20, 3) local mouse_x, mouse_y = dfhack.screen.getMousePos() if mouse_x and button_rect:inClipGlobalXY(mouse_x, mouse_y) then return true