From 0be16d44228fe01f2e5509111b84a95b9be871aa Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 14 May 2018 22:54:20 -0400 Subject: [PATCH] New tweak: stone-status-all Adds an option to toggle the economic status of all stones Also suggested by xq on IRC --- dfhack.init-example | 1 + docs/Plugins.rst | 1 + docs/changelog.txt | 3 +++ plugins/tweak/tweak.cpp | 6 +++++ plugins/tweak/tweaks/stone-status-all.h | 34 +++++++++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 plugins/tweak/tweaks/stone-status-all.h diff --git a/dfhack.init-example b/dfhack.init-example index 82210a2a6..490b1befd 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -213,6 +213,7 @@ tweak hide-priority tweak kitchen-prefs-empty tweak max-wheelbarrow tweak shift-8-scroll +tweak stone-status-all tweak title-start-rename tweak tradereq-pet-gender diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 49c86ca8a..33a2c452a 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -327,6 +327,7 @@ Subcommands that persist until disabled or DF quits: :nestbox-color: Fixes the color of built nestboxes :shift-8-scroll: Gives Shift-8 (or :kbd:`*`) priority when scrolling menus, instead of scrolling the map :stable-cursor: Saves the exact cursor position between t/q/k/d/b/etc menus of fortress mode. +:stone-status-all: Adds an option to toggle the economic status of all stones :title-start-rename: Adds a safe rename option to the title screen "Start Playing" menu :tradereq-pet-gender: Displays pet genders on the trade request screen diff --git a/docs/changelog.txt b/docs/changelog.txt index 464950660..b4e66ff59 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,6 +37,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ================================================================================ # Future +## New Tweaks +- `tweak` stone-status-all: adds an option to toggle the economic status of all stones + ## Misc Improvements - `gui/room-list`: added support for ``Gui::getSelectedBuilding()`` - `search`: added support for stone restrictions screen (under ``z``: Status) diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 37e606b1f..8d6d61db8 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -102,6 +102,7 @@ #include "tweaks/nestbox-color.h" #include "tweaks/shift-8-scroll.h" #include "tweaks/stable-cursor.h" +#include "tweaks/stone-status-all.h" #include "tweaks/title-start-rename.h" #include "tweaks/tradereq-pet-gender.h" @@ -239,6 +240,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector *input)) + { + if (input->count(interface_key::SELECT_ALL)) + { + if (VIRTUAL_CAST_VAR(list, df::layer_object_listst, layer_objects[0])) + { + bool new_state = !*stone_economic[type_tab][list->cursor]; + for (bool *economic : stone_economic[type_tab]) + *economic = new_state; + } + } + INTERPOSE_NEXT(feed)(input); + } + + DEFINE_VMETHOD_INTERPOSE(void, render, ()) + { + INTERPOSE_NEXT(render)(); + int x = 2, y = 23; + OutputHotkeyString(x, y, "All", interface_key::SELECT_ALL, + false, 0, COLOR_WHITE, COLOR_LIGHTRED); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(stone_status_all_hook, render); +IMPLEMENT_VMETHOD_INTERPOSE(stone_status_all_hook, feed);