|
|
@ -5,23 +5,6 @@ local widgets = require('gui.widgets')
|
|
|
|
|
|
|
|
|
|
|
|
local unit_selector = df.global.game.main_interface.unit_selector
|
|
|
|
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
|
|
|
|
-- UnitSelectorOverlay
|
|
|
|
--
|
|
|
|
--
|
|
|
@ -30,7 +13,8 @@ UnitSelectorOverlay = defclass(UnitSelectorOverlay, sortoverlay.SortOverlay)
|
|
|
|
UnitSelectorOverlay.ATTRS{
|
|
|
|
UnitSelectorOverlay.ATTRS{
|
|
|
|
default_pos={x=62, y=6},
|
|
|
|
default_pos={x=62, y=6},
|
|
|
|
viewscreens='dwarfmode/UnitSelector',
|
|
|
|
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)
|
|
|
|
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,
|
|
|
|
self:register_handler(name, unit_selector.unid,
|
|
|
|
curry(sortoverlay.flags_vector_search, {get_search_key_fn=get_unit_id_search_key},
|
|
|
|
curry(sortoverlay.flags_vector_search, {get_search_key_fn=get_unit_id_search_key},
|
|
|
|
unit_selector[flags_vec]))
|
|
|
|
unit_selector[flags_vec]))
|
|
|
@ -68,7 +66,7 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
function UnitSelectorOverlay:get_key()
|
|
|
|
function UnitSelectorOverlay:get_key()
|
|
|
|
local key = df.unit_selector_context_type[unit_selector.context]
|
|
|
|
local key = df.unit_selector_context_type[unit_selector.context]
|
|
|
|
if HANDLED_SCREENS[key] then
|
|
|
|
if self.handled_screens[key] then
|
|
|
|
return key
|
|
|
|
return key
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -88,4 +86,16 @@ function UnitSelectorOverlay:onInput(keys)
|
|
|
|
return UnitSelectorOverlay.super.onInput(self, keys)
|
|
|
|
return UnitSelectorOverlay.super.onInput(self, keys)
|
|
|
|
end
|
|
|
|
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
|
|
|
|
return _ENV
|
|
|
|