better panel alignment on small screen sizes

for worker assignment screen
develop
Myk Taylor 2023-10-13 14:48:44 -07:00
parent 43c353c8c7
commit 0323055e0d
No known key found for this signature in database
2 changed files with 31 additions and 20 deletions

@ -1290,6 +1290,7 @@ OVERLAY_WIDGETS = {
interrogation=require('plugins.sort.info').InterrogationOverlay,
location_selector=require('plugins.sort.locationselector').LocationSelectorOverlay,
unit_selector=require('plugins.sort.unitselector').UnitSelectorOverlay,
worker_assignment=require('plugins.sort.unitselector').WorkerAssignmentOverlay,
world=require('plugins.sort.world').WorldOverlay,
}

@ -5,23 +5,6 @@ local widgets = require('gui.widgets')
local unit_selector = df.global.game.main_interface.unit_selector
-- pen, pit, chain, and cage assignment are handled by dedicated screens
-- squad fill position screen has a specialized overlay
-- we *could* add search functionality to vanilla screens for pit and cage,
-- but then we'd have to handle the itemid vector
local HANDLED_SCREENS = {
ZONE_BEDROOM_ASSIGNMENT='already',
ZONE_OFFICE_ASSIGNMENT='already',
ZONE_DINING_HALL_ASSIGNMENT='already',
ZONE_TOMB_ASSIGNMENT='already',
-- this one should technically appear further to the left, but when the screen
-- gets small enough that that matters, the vanilla widgets are unreadable
WORKER_ASSIGNMENT='selected',
OCCUPATION_ASSIGNMENT='selected',
BURROW_ASSIGNMENT='selected',
SQUAD_KILL_ORDER='selected',
}
-- ----------------------
-- UnitSelectorOverlay
--
@ -30,7 +13,8 @@ UnitSelectorOverlay = defclass(UnitSelectorOverlay, sortoverlay.SortOverlay)
UnitSelectorOverlay.ATTRS{
default_pos={x=62, y=6},
viewscreens='dwarfmode/UnitSelector',
frame={w=26, h=1},
frame={w=31, h=1},
handled_screens=DEFAULT_NIL,
}
local function get_unit_id_search_key(unit_id)
@ -59,7 +43,21 @@ function UnitSelectorOverlay:init()
},
}
for name,flags_vec in pairs(HANDLED_SCREENS) do
-- pen, pit, chain, and cage assignment are handled by dedicated screens
-- squad fill position screen has a specialized overlay
-- we *could* add search functionality to vanilla screens for pit and cage,
-- but then we'd have to handle the itemid vector
self.handled_screens = self.handled_screens or {
ZONE_BEDROOM_ASSIGNMENT='already',
ZONE_OFFICE_ASSIGNMENT='already',
ZONE_DINING_HALL_ASSIGNMENT='already',
ZONE_TOMB_ASSIGNMENT='already',
OCCUPATION_ASSIGNMENT='selected',
BURROW_ASSIGNMENT='selected',
SQUAD_KILL_ORDER='selected',
}
for name,flags_vec in pairs(self.handled_screens) do
self:register_handler(name, unit_selector.unid,
curry(sortoverlay.flags_vector_search, {get_search_key_fn=get_unit_id_search_key},
unit_selector[flags_vec]))
@ -68,7 +66,7 @@ end
function UnitSelectorOverlay:get_key()
local key = df.unit_selector_context_type[unit_selector.context]
if HANDLED_SCREENS[key] then
if self.handled_screens[key] then
return key
end
end
@ -88,4 +86,16 @@ function UnitSelectorOverlay:onInput(keys)
return UnitSelectorOverlay.super.onInput(self, keys)
end
-- ----------------------
-- WorkerAssignmentOverlay
--
WorkerAssignmentOverlay = defclass(WorkerAssignmentOverlay, UnitSelectorOverlay)
WorkerAssignmentOverlay.ATTRS{
default_pos={x=6, y=6},
viewscreens='dwarfmode/UnitSelector',
frame={w=31, h=1},
handled_screens={WORKER_ASSIGNMENT='selected'},
}
return _ENV