From 346e8b91a9f6a8e505022bf741fcf2310afb6600 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 1 Jun 2017 23:36:02 -0400 Subject: [PATCH] Use getDwarfmodeViewDims() in getPanelLayout() Allows C++ hooks to affect Lua scripts as well --- library/lua/gui/dwarfmode.lua | 43 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/library/lua/gui/dwarfmode.lua b/library/lua/gui/dwarfmode.lua index 5f23053d8..27649bc6e 100644 --- a/library/lua/gui/dwarfmode.lua +++ b/library/lua/gui/dwarfmode.lua @@ -15,33 +15,30 @@ AREA_MAP_WIDTH = 23 MENU_WIDTH = 30 function getPanelLayout() - local sw, sh = dscreen.getWindowSize() - local view_height = sh-2 - local view_rb = sw-1 - local area_x2 = sw-AREA_MAP_WIDTH-2 - local menu_x2 = sw-MENU_WIDTH-2 - local menu_x1 = area_x2-MENU_WIDTH-1 + local dims = dfhack.gui.getDwarfmodeViewDims() local area_pos = df.global.ui_area_map_width local menu_pos = df.global.ui_menu_width - local rv = {} - if area_pos < 3 then - rv.area_map = gui.mkdims_xy(area_x2+1,1,view_rb-1,view_height) - view_rb = area_x2 + if dims.menu_forced then + menu_pos = area_pos - 1 end - if menu_pos < area_pos or df.global.ui.main.mode ~= 0 then - if menu_pos >= area_pos then - rv.menu_forced = true - menu_pos = area_pos-1 - end - local menu_x = menu_x2 - if menu_pos < 2 then menu_x = menu_x1 end - rv.menu = gui.mkdims_xy(menu_x+1,1,view_rb-1,view_height) - view_rb = menu_x + + local rv = { + menu_pos = menu_pos, + area_pos = area_pos, + map = gui.mkdims_xy(dims.map_x1, dims.map_y1, dims.map_x2, dims.map_y2), + } + + if dims.menu_forced then + rv.menu_forced = true + end + if dims.menu_on then + rv.menu = gui.mkdims_xy(dims.menu_x1, dims.y1, dims.menu_x2, dims.y2) end - rv.area_pos = area_pos - rv.menu_pos = menu_pos - rv.map = gui.mkdims_xy(1,1,view_rb-1,view_height) + if dims.area_on then + rv.area_map = gui.mkdims_xy(dims.area_x1, dims.y1, dims.area_x2, dims.y2) + end + return rv end @@ -476,7 +473,7 @@ function WorkshopOverlay:render(dc) if is_slated_for_remove(self.workshop) then return end - + WorkshopOverlay.super.render(self, dc) end return _ENV