2016-01-04 17:29:30 -07:00
|
|
|
#include "modules/Gui.h"
|
|
|
|
#include "df/viewscreen_dwarfmodest.h"
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using df::global::gps;
|
|
|
|
using df::global::ui_sidebar_menus;
|
|
|
|
|
|
|
|
struct hide_priority_hook : df::viewscreen_dwarfmodest {
|
|
|
|
typedef df::viewscreen_dwarfmodest interpose_base;
|
2021-04-05 19:58:51 -06:00
|
|
|
|
|
|
|
static bool was_valid_mode;
|
|
|
|
static bool toggled_manually;
|
|
|
|
static bool last_show_priorities_setting;
|
|
|
|
|
2016-01-04 17:29:30 -07:00
|
|
|
inline bool valid_mode ()
|
|
|
|
{
|
|
|
|
switch (ui->main.mode)
|
|
|
|
{
|
|
|
|
case df::ui_sidebar_mode::DesignateMine:
|
|
|
|
case df::ui_sidebar_mode::DesignateRemoveRamps:
|
|
|
|
case df::ui_sidebar_mode::DesignateUpStair:
|
|
|
|
case df::ui_sidebar_mode::DesignateDownStair:
|
|
|
|
case df::ui_sidebar_mode::DesignateUpDownStair:
|
|
|
|
case df::ui_sidebar_mode::DesignateUpRamp:
|
|
|
|
case df::ui_sidebar_mode::DesignateChannel:
|
|
|
|
case df::ui_sidebar_mode::DesignateGatherPlants:
|
|
|
|
case df::ui_sidebar_mode::DesignateRemoveDesignation:
|
|
|
|
case df::ui_sidebar_mode::DesignateSmooth:
|
|
|
|
case df::ui_sidebar_mode::DesignateCarveTrack:
|
|
|
|
case df::ui_sidebar_mode::DesignateEngrave:
|
|
|
|
case df::ui_sidebar_mode::DesignateCarveFortification:
|
|
|
|
case df::ui_sidebar_mode::DesignateChopTrees:
|
|
|
|
case df::ui_sidebar_mode::DesignateToggleEngravings:
|
|
|
|
case df::ui_sidebar_mode::DesignateToggleMarker:
|
|
|
|
case df::ui_sidebar_mode::DesignateRemoveConstruction:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, render, ())
|
|
|
|
{
|
2021-04-05 19:58:51 -06:00
|
|
|
if (!was_valid_mode && valid_mode() && toggled_manually) {
|
|
|
|
ui_sidebar_menus->designation.priority_set = last_show_priorities_setting;
|
|
|
|
}
|
2016-01-04 17:29:30 -07:00
|
|
|
INTERPOSE_NEXT(render)();
|
|
|
|
if (valid_mode())
|
|
|
|
{
|
|
|
|
auto dims = Gui::getDwarfmodeViewDims();
|
|
|
|
if (dims.menu_on)
|
|
|
|
{
|
|
|
|
int x = dims.menu_x1 + 1, y = gps->dimy - (gps->dimy > 26 ? 8 : 7);
|
|
|
|
OutputToggleString(x, y, "Show priorities", df::interface_key::CUSTOM_ALT_P,
|
|
|
|
ui_sidebar_menus->designation.priority_set, true, 0,
|
|
|
|
COLOR_WHITE, COLOR_LIGHTRED);
|
|
|
|
}
|
|
|
|
}
|
2021-04-05 19:58:51 -06:00
|
|
|
was_valid_mode = valid_mode();
|
2016-01-04 17:29:30 -07:00
|
|
|
}
|
|
|
|
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
|
|
|
|
{
|
|
|
|
if (valid_mode() && input->count(df::interface_key::CUSTOM_ALT_P))
|
2021-04-05 19:58:51 -06:00
|
|
|
{
|
2016-01-04 17:29:30 -07:00
|
|
|
ui_sidebar_menus->designation.priority_set = !ui_sidebar_menus->designation.priority_set;
|
2021-04-05 19:58:51 -06:00
|
|
|
toggled_manually = true;
|
|
|
|
last_show_priorities_setting = ui_sidebar_menus->designation.priority_set;
|
|
|
|
}
|
2016-01-04 17:29:30 -07:00
|
|
|
else
|
|
|
|
INTERPOSE_NEXT(feed)(input);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-05 19:58:51 -06:00
|
|
|
bool hide_priority_hook::was_valid_mode = false;
|
|
|
|
bool hide_priority_hook::toggled_manually = false;
|
|
|
|
bool hide_priority_hook::last_show_priorities_setting = false;
|
|
|
|
|
2016-01-04 17:29:30 -07:00
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, feed);
|
|
|
|
IMPLEMENT_VMETHOD_INTERPOSE(hide_priority_hook, render);
|