new tweak: hotkey-clear

develop
lethosor 2017-04-19 13:31:25 -04:00
parent 93a977bf5c
commit 06737644cd
4 changed files with 51 additions and 0 deletions

@ -184,6 +184,9 @@ tweak import-priority-category
# Fixes a crash in the work order contition material list (bug 9905).
tweak condition-material
# Adds an option to clear currently-bound hotkeys
tweak hotkey-clear
# Misc. UI tweaks
tweak block-labors # Prevents labors that can't be used from being toggled
tweak civ-view-agreement

@ -287,6 +287,7 @@ Subcommands that persist until disabled or DF quits:
the current item (fully, in case of a stack), and scroll down one line.
:fps-min: Fixes the in-game minimum FPS setting
:hide-priority: Adds an option to hide designation priority indicators
:hotkey-clear: Adds an option to clear currently-bound hotkeys (in the :kbd:`H` menu)
:import-priority-category:
Allows changing the priority of all goods in a
category when discussing an import agreement with the liaison

@ -90,6 +90,7 @@
#include "tweaks/fast-trade.h"
#include "tweaks/fps-min.h"
#include "tweaks/hide-priority.h"
#include "tweaks/hotkey-clear.h"
#include "tweaks/import-priority-category.h"
#include "tweaks/kitchen-keys.h"
#include "tweaks/kitchen-prefs-color.h"
@ -205,6 +206,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes the in-game minimum FPS setting (bug 6277)\n"
" tweak hide-priority [disable]\n"
" Adds an option to hide designation priority indicators\n"
" tweak hotkey-clear [disable] \n"
" Adds an option to clear currently-bound hotkeys\n"
" tweak import-priority-category [disable]\n"
" When meeting with a liaison, makes Shift+Left/Right arrow adjust\n"
" the priority of an entire category of imports.\n"
@ -272,6 +275,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("hide-priority", hide_priority_hook, feed);
TWEAK_HOOK("hide-priority", hide_priority_hook, render);
TWEAK_HOOK("hotkey-clear", hotkey_clear_hook, feed);
TWEAK_HOOK("hotkey-clear", hotkey_clear_hook, render);
TWEAK_HOOK("import-priority-category", takerequest_hook, feed);
TWEAK_HOOK("import-priority-category", takerequest_hook, render);

@ -0,0 +1,41 @@
#include "df/viewscreen_dwarfmodest.h"
using df::global::ui;
struct hotkey_clear_hook : df::viewscreen_dwarfmodest {
typedef df::viewscreen_dwarfmodest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, render, ())
{
INTERPOSE_NEXT(render)();
if (ui->main.mode == df::ui_sidebar_mode::Hotkeys)
{
int x = 26, y = 19;
OutputHotkeyString(x, y, "Clear", df::interface_key::CUSTOM_C, false, 0, COLOR_WHITE, COLOR_LIGHTRED);
}
}
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))
{
if (ui->main.mode == df::ui_sidebar_mode::Hotkeys &&
input->count(df::interface_key::CUSTOM_C) &&
!ui->main.in_rename_hotkey)
{
auto &hotkey = ui->main.hotkeys[ui->main.selected_hotkey];
hotkey.name = "";
hotkey.cmd = df::ui_hotkey::T_cmd::None;
hotkey.x = 0;
hotkey.y = 0;
hotkey.z = 0;
hotkey.unit_id = 0;
hotkey.item_id = 0;
}
else
{
INTERPOSE_NEXT(feed)(input);
}
}
};
IMPLEMENT_VMETHOD_INTERPOSE(hotkey_clear_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(hotkey_clear_hook, render);