add minimize/restore button

develop
Myk Taylor 2023-03-15 01:19:34 -07:00
parent c6fefb3599
commit 208a3e4ae8
No known key found for this signature in database
2 changed files with 23 additions and 3 deletions

@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
-@ `buildingplan`: remember choice per building type for whether the player wants to choose specific items -@ `buildingplan`: remember choice per building type for whether the player wants to choose specific items
-@ `buildingplan`: you can now attach multiple weapons to spike traps -@ `buildingplan`: you can now attach multiple weapons to spike traps
-@ `buildingplan`: can now filter by whether a slab is engraved -@ `buildingplan`: can now filter by whether a slab is engraved
-@ `buildingplan`: add "minimize" button to temporarily get the planner overlay out of the way if you would rather use the vanilla UI for placing the current building
- `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory - `blueprint`: now writes blueprints to the ``dfhack-config/blueprints`` directory
- `blueprint-library-guide`: library blueprints have moved from ``blueprints`` to ``hack/data/blueprints`` - `blueprint-library-guide`: library blueprints have moved from ``blueprints`` to ``hack/data/blueprints``
- player-created blueprints should now go in the ``dfhack-config/blueprints`` folder. please move your existing blueprints from ``blueprints`` to ``dfhack-config/blueprints``. you don't need to move the library blueprints -- those can be safely deleted from the old ``blueprints`` directory. - player-created blueprints should now go in the ``dfhack-config/blueprints`` folder. please move your existing blueprints from ``blueprints`` to ``dfhack-config/blueprints``. you don't need to move the library blueprints -- those can be safely deleted from the old ``blueprints`` directory.

@ -260,12 +260,17 @@ PlannerOverlay.ATTRS{
function PlannerOverlay:init() function PlannerOverlay:init()
self.selected = 1 self.selected = 1
self.minimized = false
local function is_minimized() return self.minimized end
local function not_is_minimized() return not self.minimized end
local main_panel = widgets.Panel{ local main_panel = widgets.Panel{
view_id='main', view_id='main',
frame={t=0, l=0, r=0, h=14}, frame={t=0, l=0, r=0, h=14},
frame_style=gui.MEDIUM_FRAME, frame_style=gui.MEDIUM_FRAME,
frame_background=gui.CLEAR_PEN, frame_background=gui.CLEAR_PEN,
visible=function() return not self.minimized end,
} }
local function make_is_selected_fn(idx) local function make_is_selected_fn(idx)
@ -451,6 +456,7 @@ function PlannerOverlay:init()
frame={t=14, l=0, r=0}, frame={t=14, l=0, r=0},
frame_style=gui.MEDIUM_FRAME, frame_style=gui.MEDIUM_FRAME,
frame_background=gui.CLEAR_PEN, frame_background=gui.CLEAR_PEN,
visible=function() return not self.minimized end,
} }
error_panel:addviews{ error_panel:addviews{
@ -565,11 +571,16 @@ function PlannerOverlay:onInput(keys)
return true return true
end end
self.selected = 1 self.selected = 1
self.minimized = false
self.subviews.hollow:setOption(false) self.subviews.hollow:setOption(false)
self:reset() self:reset()
reset_counts_flag = true reset_counts_flag = true
return false return false
end end
if keys.CUSTOM_ALT_M then
self.minimized = not self.minimized
return true
end
if PlannerOverlay.super.onInput(self, keys) then if PlannerOverlay.super.onInput(self, keys) then
return true return true
end end
@ -579,10 +590,15 @@ function PlannerOverlay:onInput(keys)
detect_rect.height = self.subviews.main.frame_rect.height + detect_rect.height = self.subviews.main.frame_rect.height +
self.subviews.errors.frame_rect.height self.subviews.errors.frame_rect.height
detect_rect.y2 = detect_rect.y1 + detect_rect.height - 1 detect_rect.y2 = detect_rect.y1 + detect_rect.height - 1
if self.subviews.main:getMousePos(gui.ViewRect{rect=detect_rect}) local x, y = self.subviews.main:getMousePos(gui.ViewRect{rect=detect_rect})
or self.subviews.errors:getMousePos() then if x or self.subviews.errors:getMousePos() then
if x and x == detect_rect.width-2 and y == 0 then
self.minimized = not self.minimized
return true return true
end end
return not self.minimized
end
if self.minimized then return false end
if not is_construction() and #uibs.errors > 0 then return true end if not is_construction() and #uibs.errors > 0 then return true end
if dfhack.gui.getMousePos() then if dfhack.gui.getMousePos() then
if is_choosing_area() or cur_building_has_no_area() then if is_choosing_area() or cur_building_has_no_area() then
@ -642,6 +658,9 @@ function PlannerOverlay:render(dc)
if not is_plannable() then return end if not is_plannable() then return end
self.subviews.errors:updateLayout() self.subviews.errors:updateLayout()
PlannerOverlay.super.render(self, dc) PlannerOverlay.super.render(self, dc)
-- render "minimize" button
dc:seek(self.frame_rect.x2-1, self.frame_rect.y1)
dc:char(string.char(self.minimized and 31 or 30), COLOR_RED)
end end
local ONE_BY_ONE = xy2pos(1, 1) local ONE_BY_ONE = xy2pos(1, 1)