From 3ee059317f5cca16eb915c651418fd4bae8e4b58 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 9 Oct 2023 03:45:53 -0700 Subject: [PATCH 1/2] add help button to squad panel --- docs/changelog.txt | 1 + plugins/lua/sort.lua | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index fbe37deff..56a1237c1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -64,6 +64,7 @@ Template for new versions: ## Misc Improvements - `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates - `orders`: ``recheck`` command now only resets orders that have conditions that can be rechecked +- `sort`: added help button for squad assignment search/filter/sort ## Documentation diff --git a/plugins/lua/sort.lua b/plugins/lua/sort.lua index 174c7005e..52bfac7aa 100644 --- a/plugins/lua/sort.lua +++ b/plugins/lua/sort.lua @@ -4,6 +4,7 @@ local info = require('plugins.sort.info') local gui = require('gui') local overlay = require('plugins.overlay') local setbelief = reqscript('modtools/set-belief') +local textures = require('gui.textures') local utils = require('utils') local widgets = require('gui.widgets') @@ -631,10 +632,6 @@ SquadAssignmentOverlay.ATTRS{ viewscreens='dwarfmode/UnitSelector/SQUAD_FILL_POSITION', version='2', frame={w=38, h=31}, - frame_style=gui.FRAME_PANEL, - frame_background=gui.CLEAR_PEN, - autoarrange_subviews=true, - autoarrange_gap=1, } -- allow initial spacebar or two successive spacebars to fall through and @@ -661,7 +658,14 @@ function SquadAssignmentOverlay:init() }) end - self:addviews{ + local main_panel = widgets.Panel{ + frame={l=0, r=0, t=0, b=0}, + frame_style=gui.FRAME_PANEL, + frame_background=gui.CLEAR_PEN, + autoarrange_subviews=true, + autoarrange_gap=1, + } + main_panel:addviews{ widgets.EditField{ view_id='search', frame={l=0}, @@ -940,6 +944,26 @@ function SquadAssignmentOverlay:init() on_change=function() self:refresh_list() end, }, } + + local button_pen_left = dfhack.pen.parse{fg=COLOR_CYAN, + tile=curry(textures.tp_control_panel, 7) or nil, ch=string.byte('[')} + local button_pen_right = dfhack.pen.parse{fg=COLOR_CYAN, + tile=curry(textures.tp_control_panel, 8) or nil, ch=string.byte(']')} + local help_pen_center = dfhack.pen.parse{ + tile=curry(textures.tp_control_panel, 9) or nil, ch=string.byte('?')} + + self:addviews{ + main_panel, + widgets.Label{ + frame={t=0, r=1, w=3}, + text={ + {tile=button_pen_left}, + {tile=help_pen_center}, + {tile=button_pen_right}, + }, + on_click=function() dfhack.run_command('gui/launcher', 'sort ') end, + }, + } end local function normalize_search_key(search_key) From 640c77dc48f8933eeb06c1efbdd15c07e0a55940 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 9 Oct 2023 17:31:50 -0700 Subject: [PATCH 2/2] dungeon cages/retraints aren't assignable --- docs/changelog.txt | 1 + plugins/lua/zone.lua | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index fbe37deff..59868e902 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -60,6 +60,7 @@ Template for new versions: - `sort`: new search widgets for Info panel tabs, including all "Creatures" subtabs, all "Objects" subtabs, "Tasks", the "Work details" subtab under "Labor", and the "Interrogate" and "Convict" screens under "Justice" ## Fixes +- `zone`: don't show animal assignment link for dungeon cages/restraints ## Misc Improvements - `overlay`: allow ``overlay_onupdate_max_freq_seconds`` to be dynamically set to 0 for a burst of high-frequency updates diff --git a/plugins/lua/zone.lua b/plugins/lua/zone.lua index 13182cef1..eb984093b 100644 --- a/plugins/lua/zone.lua +++ b/plugins/lua/zone.lua @@ -961,9 +961,13 @@ CageChainOverlay.ATTRS{ local function is_valid_building() local bld = dfhack.gui.getSelectedBuilding(true) - return bld and bld:getBuildStage() == bld:getMaxBuildStage() and - (bld:getType() == df.building_type.Cage or - bld:getType() == df.building_type.Chain) + if not bld or bld:getBuildStage() ~= bld:getMaxBuildStage() then return false end + local bt = bld:getType() + if bt ~= df.building_type.Cage and bt ~= df.building_type.Chain then return false end + for _,zone in ipairs(bld.relations) do + if zone.type == df.civzone_type.Dungeon then return false end + end + return true end local function is_cage_selected()