New tweak: stone-status-all

Adds an option to toggle the economic status of all stones

Also suggested by xq on IRC
develop
lethosor 2018-05-14 22:54:20 -04:00
parent 914b376082
commit 0be16d4422
5 changed files with 45 additions and 0 deletions

@ -213,6 +213,7 @@ tweak hide-priority
tweak kitchen-prefs-empty tweak kitchen-prefs-empty
tweak max-wheelbarrow tweak max-wheelbarrow
tweak shift-8-scroll tweak shift-8-scroll
tweak stone-status-all
tweak title-start-rename tweak title-start-rename
tweak tradereq-pet-gender tweak tradereq-pet-gender

@ -327,6 +327,7 @@ Subcommands that persist until disabled or DF quits:
:nestbox-color: Fixes the color of built nestboxes :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 :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. :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 :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 :tradereq-pet-gender: Displays pet genders on the trade request screen

@ -37,6 +37,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
================================================================================ ================================================================================
# Future # Future
## New Tweaks
- `tweak` stone-status-all: adds an option to toggle the economic status of all stones
## Misc Improvements ## Misc Improvements
- `gui/room-list`: added support for ``Gui::getSelectedBuilding()`` - `gui/room-list`: added support for ``Gui::getSelectedBuilding()``
- `search`: added support for stone restrictions screen (under ``z``: Status) - `search`: added support for stone restrictions screen (under ``z``: Status)

@ -102,6 +102,7 @@
#include "tweaks/nestbox-color.h" #include "tweaks/nestbox-color.h"
#include "tweaks/shift-8-scroll.h" #include "tweaks/shift-8-scroll.h"
#include "tweaks/stable-cursor.h" #include "tweaks/stable-cursor.h"
#include "tweaks/stone-status-all.h"
#include "tweaks/title-start-rename.h" #include "tweaks/title-start-rename.h"
#include "tweaks/tradereq-pet-gender.h" #include "tweaks/tradereq-pet-gender.h"
@ -239,6 +240,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" tweak shift-8-scroll [disable]\n" " tweak shift-8-scroll [disable]\n"
" Gives Shift+8 (or *) priority when scrolling menus, instead of \n" " Gives Shift+8 (or *) priority when scrolling menus, instead of \n"
" scrolling the map\n" " scrolling the map\n"
" tweak stone-status-all [disable]\n"
" Adds an option to toggle the economic status of all stones\n"
" tweak title-start-rename [disable]\n" " tweak title-start-rename [disable]\n"
" Adds a safe rename option to the title screen \"Start Playing\" menu\n" " Adds a safe rename option to the title screen \"Start Playing\" menu\n"
" tweak tradereq-pet-gender [disable]\n" " tweak tradereq-pet-gender [disable]\n"
@ -314,6 +317,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("stable-cursor", stable_cursor_hook, feed); TWEAK_HOOK("stable-cursor", stable_cursor_hook, feed);
TWEAK_HOOK("stone-status-all", stone_status_all_hook, feed);
TWEAK_HOOK("stone-status-all", stone_status_all_hook, render);
TWEAK_HOOK("title-start-rename", title_start_rename_hook, feed); TWEAK_HOOK("title-start-rename", title_start_rename_hook, feed);
TWEAK_HOOK("title-start-rename", title_start_rename_hook, render); TWEAK_HOOK("title-start-rename", title_start_rename_hook, render);

@ -0,0 +1,34 @@
#include "df/interface_key.h"
#include "df/layer_object_listst.h"
#include "df/viewscreen_layer_stone_restrictionst.h"
using namespace DFHack;
struct stone_status_all_hook : df::viewscreen_layer_stone_restrictionst {
typedef df::viewscreen_layer_stone_restrictionst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set<df::interface_key> *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);