|
|
@ -62,12 +62,16 @@ local function do_export()
|
|
|
|
}:show()
|
|
|
|
}:show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function do_recheck()
|
|
|
|
|
|
|
|
dfhack.run_command('orders', 'recheck')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget)
|
|
|
|
OrdersOverlay = defclass(OrdersOverlay, overlay.OverlayWidget)
|
|
|
|
OrdersOverlay.ATTRS{
|
|
|
|
OrdersOverlay.ATTRS{
|
|
|
|
default_pos={x=53,y=-6},
|
|
|
|
default_pos={x=53,y=-6},
|
|
|
|
default_enabled=true,
|
|
|
|
default_enabled=true,
|
|
|
|
viewscreens='dwarfmode/Info/WORK_ORDERS/Default',
|
|
|
|
viewscreens='dwarfmode/Info/WORK_ORDERS/Default',
|
|
|
|
frame={w=30, h=4},
|
|
|
|
frame={w=46, h=4},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function OrdersOverlay:init()
|
|
|
|
function OrdersOverlay:init()
|
|
|
@ -95,13 +99,20 @@ function OrdersOverlay:init()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
widgets.HotkeyLabel{
|
|
|
|
widgets.HotkeyLabel{
|
|
|
|
frame={t=0, l=15},
|
|
|
|
frame={t=0, l=15},
|
|
|
|
|
|
|
|
label='recheck',
|
|
|
|
|
|
|
|
key='CUSTOM_CTRL_R',
|
|
|
|
|
|
|
|
auto_width=true,
|
|
|
|
|
|
|
|
on_activate=do_recheck,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
widgets.HotkeyLabel{
|
|
|
|
|
|
|
|
frame={t=1, l=15},
|
|
|
|
label='sort',
|
|
|
|
label='sort',
|
|
|
|
key='CUSTOM_CTRL_O',
|
|
|
|
key='CUSTOM_CTRL_O',
|
|
|
|
auto_width=true,
|
|
|
|
auto_width=true,
|
|
|
|
on_activate=do_sort,
|
|
|
|
on_activate=do_sort,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
widgets.HotkeyLabel{
|
|
|
|
widgets.HotkeyLabel{
|
|
|
|
frame={t=1, l=15},
|
|
|
|
frame={t=0, l=31},
|
|
|
|
label='clear',
|
|
|
|
label='clear',
|
|
|
|
key='CUSTOM_CTRL_C',
|
|
|
|
key='CUSTOM_CTRL_C',
|
|
|
|
auto_width=true,
|
|
|
|
auto_width=true,
|
|
|
@ -157,7 +168,91 @@ function OrdersOverlay:render(dc)
|
|
|
|
OrdersOverlay.super.render(self, dc)
|
|
|
|
OrdersOverlay.super.render(self, dc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Resets the selected work order to the `Checking` state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function set_current_inactive()
|
|
|
|
|
|
|
|
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
|
|
|
|
|
|
|
|
if scrConditions.open then
|
|
|
|
|
|
|
|
dfhack.run_command('orders', 'recheck', 'this')
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
qerror("Order conditions is not open")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function is_current_active()
|
|
|
|
|
|
|
|
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
|
|
|
|
|
|
|
|
local order = scrConditions.wq
|
|
|
|
|
|
|
|
return order.status.active
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- -------------------
|
|
|
|
|
|
|
|
-- RecheckOverlay
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local focusString = 'dwarfmode/Info/WORK_ORDERS/Conditions'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecheckOverlay = defclass(RecheckOverlay, overlay.OverlayWidget)
|
|
|
|
|
|
|
|
RecheckOverlay.ATTRS{
|
|
|
|
|
|
|
|
default_pos={x=6,y=8},
|
|
|
|
|
|
|
|
default_enabled=true,
|
|
|
|
|
|
|
|
viewscreens=focusString,
|
|
|
|
|
|
|
|
-- width is the sum of lengths of `[` + `Ctrl+A` + `: ` + button.label + `]`
|
|
|
|
|
|
|
|
frame={w=1 + 6 + 2 + 16 + 1, h=3},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function areTabsInTwoRows()
|
|
|
|
|
|
|
|
-- get the tile above the order status icon
|
|
|
|
|
|
|
|
local pen = dfhack.screen.readTile(7, 7, false)
|
|
|
|
|
|
|
|
-- in graphics mode, `0` when one row, something else when two (`67` aka 'C' from "Creatures")
|
|
|
|
|
|
|
|
-- in ASCII mode, `32` aka ' ' when one row, something else when two (`196` aka '-' from tab frame's top)
|
|
|
|
|
|
|
|
return (pen.ch ~= 0 and pen.ch ~= 32)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RecheckOverlay:updateTextButtonFrame()
|
|
|
|
|
|
|
|
local twoRows = areTabsInTwoRows()
|
|
|
|
|
|
|
|
if (self._twoRows == twoRows) then return false end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._twoRows = twoRows
|
|
|
|
|
|
|
|
local frame = twoRows
|
|
|
|
|
|
|
|
and {b=0, l=0, r=0, h=1}
|
|
|
|
|
|
|
|
or {t=0, l=0, r=0, h=1}
|
|
|
|
|
|
|
|
self.subviews.button.frame = frame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RecheckOverlay:init()
|
|
|
|
|
|
|
|
self:addviews{
|
|
|
|
|
|
|
|
widgets.TextButton{
|
|
|
|
|
|
|
|
view_id = 'button',
|
|
|
|
|
|
|
|
-- frame={t=0, l=0, r=0, h=1}, -- is set in `updateTextButtonFrame()`
|
|
|
|
|
|
|
|
label='request re-check',
|
|
|
|
|
|
|
|
key='CUSTOM_CTRL_A',
|
|
|
|
|
|
|
|
on_activate=set_current_inactive,
|
|
|
|
|
|
|
|
enabled=is_current_active,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self:updateTextButtonFrame()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RecheckOverlay:onRenderBody(dc)
|
|
|
|
|
|
|
|
if (self.frame_rect.y1 == 7) then
|
|
|
|
|
|
|
|
-- only apply this logic if the overlay is on the same row as
|
|
|
|
|
|
|
|
-- originally thought: just above the order status icon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self:updateTextButtonFrame() then
|
|
|
|
|
|
|
|
self:updateLayout()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecheckOverlay.super.onRenderBody(self, dc)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- -------------------
|
|
|
|
|
|
|
|
|
|
|
|
OVERLAY_WIDGETS = {
|
|
|
|
OVERLAY_WIDGETS = {
|
|
|
|
|
|
|
|
recheck=RecheckOverlay,
|
|
|
|
overlay=OrdersOverlay,
|
|
|
|
overlay=OrdersOverlay,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|