Merge pull request #3078 from myk002/myk_orders

add minimize button to orders overlay panel
develop
Myk 2023-03-23 03:24:30 -07:00 committed by GitHub
commit 4d540ba8ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 27 deletions

@ -47,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `stockpiles`: write player-exported stockpile configurations to the ``dfhack-config/stockpiles`` folder. If you have any stockpile configs in other directories, please move them to that folder. - `stockpiles`: write player-exported stockpile configurations to the ``dfhack-config/stockpiles`` folder. If you have any stockpile configs in other directories, please move them to that folder.
- `stockpiles`: now includes a library of useful stockpile configs (see docs for details) - `stockpiles`: now includes a library of useful stockpile configs (see docs for details)
- `automelt`: now allows metal chests to be melted (workaround for DF bug 2493 is no longer needed) - `automelt`: now allows metal chests to be melted (workaround for DF bug 2493 is no longer needed)
- `orders`: add minimize button to overlay panel so you can get it out of the way to read long statue descriptions when choosing a subject in the details screen
## Documentation ## Documentation

@ -48,8 +48,11 @@ is open via an `overlay` widget. There are hotkeys assigned to export, import,
sort, and clear. You can also click on the hotkey hints as if they were buttons. sort, and clear. You can also click on the hotkey hints as if they were buttons.
Clearing will ask for confirmation before acting. Clearing will ask for confirmation before acting.
If you want to change where the hotkey hints appear, you can move them via If you want to change where the overlay panel appears, you can move it via
`gui/overlay`. `gui/overlay`. If you just need to get the overlay out of the way temporarily,
for example to read a long description of a historical figure when choosing a
subject for a statue, click on the small arrow in the upper right corner of the
overlay panel. Click on the arrow again to restore the panel.
The orders library The orders library
------------------ ------------------

@ -46,39 +46,89 @@ OrdersOverlay.ATTRS{
default_enabled=true, default_enabled=true,
viewscreens='dwarfmode/Info/WORK_ORDERS', viewscreens='dwarfmode/Info/WORK_ORDERS',
frame={w=30, h=4}, frame={w=30, h=4},
frame_style=gui.MEDIUM_FRAME,
frame_background=gui.CLEAR_PEN,
} }
function OrdersOverlay:init() function OrdersOverlay:init()
self:addviews{ self.minimized = false
local main_panel = widgets.Panel{
frame={t=0, l=0, r=0, h=4},
frame_style=gui.MEDIUM_FRAME,
frame_background=gui.CLEAR_PEN,
visible=function() return not self.minimized end,
subviews={
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=0, l=0}, frame={t=0, l=0},
label='import', label='import',
key='CUSTOM_CTRL_I', key='CUSTOM_CTRL_I',
auto_width=true,
on_activate=do_import, on_activate=do_import,
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=1, l=0}, frame={t=1, l=0},
label='export', label='export',
key='CUSTOM_CTRL_E', key='CUSTOM_CTRL_E',
auto_width=true,
on_activate=do_export, on_activate=do_export,
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=0, l=15}, frame={t=0, l=15},
label='sort', label='sort',
key='CUSTOM_CTRL_O', key='CUSTOM_CTRL_O',
auto_width=true,
on_activate=do_sort, on_activate=do_sort,
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={t=1, l=15}, frame={t=1, l=15},
label='clear', label='clear',
key='CUSTOM_CTRL_C', key='CUSTOM_CTRL_C',
auto_width=true,
on_activate=do_clear, on_activate=do_clear,
}, },
},
}
local minimized_panel = widgets.Panel{
frame={t=0, r=0, w=3, h=1},
subviews={
widgets.Label{
frame={t=0, l=0, w=1, h=1},
text='[',
text_pen=COLOR_RED,
visible=function() return self.minimized end,
},
widgets.Label{
frame={t=0, l=1, w=1, h=1},
text={{text=function() return self.minimized and string.char(31) or string.char(30) end}},
text_pen=dfhack.pen.parse{fg=COLOR_BLACK, bg=COLOR_GREY},
text_hpen=dfhack.pen.parse{fg=COLOR_BLACK, bg=COLOR_WHITE},
on_click=function() self.minimized = not self.minimized end,
},
widgets.Label{
frame={t=0, r=0, w=1, h=1},
text=']',
text_pen=COLOR_RED,
visible=function() return self.minimized end,
},
},
}
self:addviews{
main_panel,
minimized_panel,
} }
end end
function OrdersOverlay:onInput(keys)
if keys.CUSTOM_ALT_M then
self.minimized = not self.minimized
return true
end
if OrdersOverlay.super.onInput(self, keys) then
return true
end
end
OVERLAY_WIDGETS = { OVERLAY_WIDGETS = {
overlay=OrdersOverlay, overlay=OrdersOverlay,
} }