Add "tweak burrow-name-cancel" to fix bug 1518

http://www.bay12games.com/dwarves/mantisbt/view.php?id=1518

Closes #526
develop
lethosor 2017-06-25 16:42:30 -04:00
parent 10e13c532a
commit fe8be90992
5 changed files with 52 additions and 0 deletions

@ -198,6 +198,7 @@ tweak embark-profile-name
# Misc. UI tweaks
tweak block-labors # Prevents labors that can't be used from being toggled
tweak burrow-name-cancel
tweak cage-butcher
tweak civ-view-agreement
tweak eggs-fertile

@ -275,6 +275,8 @@ Subcommands that persist until disabled or DF quits:
the contents separately from the container. This forcefully skips child
reagents.
:block-labors: Prevents labors that can't be used from being toggled
:burrow-name-cancel: Implements the "back" option when renaming a burrow,
which currently does nothing (:bug:`1518`)
:cage-butcher: Adds an option to butcher units when viewing cages with :kbd:`q`
:civ-view-agreement: Fixes overlapping text on the "view agreement" screen
:condition-material: Fixes a crash in the work order contition material list (:bug:`9905`).

@ -80,6 +80,7 @@
#include "tweaks/adamantine-cloth-wear.h"
#include "tweaks/advmode-contained.h"
#include "tweaks/block-labors.h"
#include "tweaks/burrow-name-cancel.h"
#include "tweaks/cage-butcher.h"
#include "tweaks/civ-agreement-ui.h"
#include "tweaks/condition-material.h"
@ -184,6 +185,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes custom reactions with container inputs in advmode. The issue is\n"
" that the screen tries to force you to select the contents separately\n"
" from the container. This forcefully skips child reagents.\n"
" tweak burrow-name-cancel [disable]\n"
" Implements the \"back\" option when renaming a burrow.\n"
" tweak block-labors [disable]\n"
" Prevents labors that can't be used from being toggled.\n"
" tweak cage-butcher [disable]\n"
@ -255,6 +258,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("block-labors", block_labors_hook, feed);
TWEAK_HOOK("block-labors", block_labors_hook, render);
TWEAK_HOOK("burrow-name-cancel", burrow_name_cancel_hook, feed);
TWEAK_HOOK("cage-butcher", cage_butcher_hook, feed);
TWEAK_HOOK("cage-butcher", cage_butcher_hook, render);

@ -0,0 +1,44 @@
#include "df/burrow.h"
using df::global::ui;
struct burrow_name_cancel_hook : df::viewscreen_dwarfmodest {
typedef df::viewscreen_dwarfmodest interpose_base;
static std::string old_name;
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *input))
{
if (ui->main.mode == df::ui_sidebar_mode::Burrows)
{
bool was_naming = ui->burrows.in_edit_name_mode;
INTERPOSE_NEXT(feed)(input);
df::burrow *burrow = vector_get(ui->burrows.list, ui->burrows.sel_index);
if (!burrow)
return;
if (ui->burrows.in_edit_name_mode)
{
if (!was_naming)
{
// Just started renaming - make a copy of the old name
old_name = burrow->name;
}
if (input->count(df::interface_key::LEAVESCREEN))
{
// Cancel and restore the old name
ui->burrows.in_edit_name_mode = false;
burrow->name = old_name;
}
}
}
else
{
INTERPOSE_NEXT(feed)(input);
}
}
};
std::string burrow_name_cancel_hook::old_name;
IMPLEMENT_VMETHOD_INTERPOSE(burrow_name_cancel_hook, feed);