Merge remote-tracking branch 'lethosor/tweak-hide-priority-improvements' into develop

develop
lethosor 2021-04-08 23:43:14 -04:00
commit e2d56b9b8f
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 20 additions and 0 deletions

@ -37,6 +37,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `buildingplan`: fixed an issue where planned constructions designated with DF's sizing keys (``umkh``) would sometimes be larger than requested - `buildingplan`: fixed an issue where planned constructions designated with DF's sizing keys (``umkh``) would sometimes be larger than requested
- `command-prompt`: fixed issues where overlays created by running certain commands (e.g. `gui/liquids`, `gui/teleport`) would not update the parent screen correctly - `command-prompt`: fixed issues where overlays created by running certain commands (e.g. `gui/liquids`, `gui/teleport`) would not update the parent screen correctly
## Misc Improvements
- `tweak` hide-priority: changed so that priorities stay hidden (or visible) when exiting and re-entering the designations menu
## Lua ## Lua
- ``gui.Painter``: fixed error when calling ``viewport()`` method - ``gui.Painter``: fixed error when calling ``viewport()`` method
- `xlsxreader`: Added Lua class wrappers for the xlsxreader plugin API - `xlsxreader`: Added Lua class wrappers for the xlsxreader plugin API

@ -7,6 +7,11 @@ using df::global::ui_sidebar_menus;
struct hide_priority_hook : df::viewscreen_dwarfmodest { struct hide_priority_hook : df::viewscreen_dwarfmodest {
typedef df::viewscreen_dwarfmodest interpose_base; typedef df::viewscreen_dwarfmodest interpose_base;
static bool was_valid_mode;
static bool toggled_manually;
static bool last_show_priorities_setting;
inline bool valid_mode () inline bool valid_mode ()
{ {
switch (ui->main.mode) switch (ui->main.mode)
@ -35,6 +40,9 @@ struct hide_priority_hook : df::viewscreen_dwarfmodest {
} }
DEFINE_VMETHOD_INTERPOSE(void, render, ()) DEFINE_VMETHOD_INTERPOSE(void, render, ())
{ {
if (!was_valid_mode && valid_mode() && toggled_manually) {
ui_sidebar_menus->designation.priority_set = last_show_priorities_setting;
}
INTERPOSE_NEXT(render)(); INTERPOSE_NEXT(render)();
if (valid_mode()) if (valid_mode())
{ {
@ -47,15 +55,24 @@ struct hide_priority_hook : df::viewscreen_dwarfmodest {
COLOR_WHITE, COLOR_LIGHTRED); COLOR_WHITE, COLOR_LIGHTRED);
} }
} }
was_valid_mode = valid_mode();
} }
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input)) DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
{ {
if (valid_mode() && input->count(df::interface_key::CUSTOM_ALT_P)) if (valid_mode() && input->count(df::interface_key::CUSTOM_ALT_P))
{
ui_sidebar_menus->designation.priority_set = !ui_sidebar_menus->designation.priority_set; ui_sidebar_menus->designation.priority_set = !ui_sidebar_menus->designation.priority_set;
toggled_manually = true;
last_show_priorities_setting = ui_sidebar_menus->designation.priority_set;
}
else else
INTERPOSE_NEXT(feed)(input); INTERPOSE_NEXT(feed)(input);
} }
}; };
bool hide_priority_hook::was_valid_mode = false;
bool hide_priority_hook::toggled_manually = false;
bool hide_priority_hook::last_show_priorities_setting = false;
IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, feed); IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, render); IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, render);