From abc60f53ad60d6179ccde8e8df343ab624be51e3 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 17 Feb 2015 10:43:55 -0500 Subject: [PATCH 1/4] Add `tweak shift-8-scroll`; misc. tweak plugin changes * Avoid dumping complete usage information for unrecognized tweaks * Alphabetize tweaks in Readme.rst --- NEWS | 1 + Readme.rst | 43 +++++++++++++-------------- plugins/tweak/tweak.cpp | 9 +++++- plugins/tweak/tweaks/shift-8-scroll.h | 21 +++++++++++++ 4 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 plugins/tweak/tweaks/shift-8-scroll.h diff --git a/NEWS b/NEWS index 499fe0c37..74e243dcc 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ DFHack Future New Scripts modtools/reaction-product-trigger: triggers callbacks when products are produced (contrast with when reactions complete) New Tweaks + shift-8-scroll: Gives Shift+8 (or *) priority when scrolling menus, instead of scrolling the map tradereq-pet-gender: Displays pet genders on the trade request screen Removed Misc Improvements diff --git a/Readme.rst b/Readme.rst index ac4953f54..0de7eb44e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1292,40 +1292,39 @@ One-shot subcommands: for slaughter. Grabbing wagons results in some funny spam, then they are scuttled. -Subcommands that persist until disabled or DF quit: +Subcommands that persist until disabled or DF quits: -:stable-cursor: Saves the exact cursor position between t/q/k/d/etc menus of dwarfmode. +:adamantine-cloth-wear: Prevents adamantine clothing from wearing out while being worn (bug 6481). +:advmode-contained: Works around bug 6202, i.e. custom reactions with container inputs + in advmode. The issue is that the screen tries to force you to select + the contents separately from the container. This forcefully skips child + reagents. +:civ-view-agreement: Fixes overlapping text on the "view agreement" screen +:craft-age-wear: Fixes the behavior of crafted items wearing out over time (bug 6003). + With this tweak, items made from cloth and leather will gain a level of wear every 20 years. +:eggs-fertile: Displays a fertility indicator on nestboxes +:farm-plot-select: Adds "Select all" and "Deselect all" options to farm plot menus :fast-heat: Further improves temperature update performance by ensuring that 1 degree of item temperature is crossed in no more than specified number of frames when updating from the environment temperature. This reduces the time it takes for stable-temp to stop updates again when equilibrium is disturbed. -:advmode-contained: Works around bug 6202, i.e. custom reactions with container inputs - in advmode. The issue is that the screen tries to force you to select - the contents separately from the container. This forcefully skips child - reagents. :fast-trade: Makes Shift-Down in the Move Goods to Depot and Trade screens select the current item (fully, in case of a stack), and scroll down one line. +:import-priority-category: Allows changing the priority of all goods in a + category when discussing an import agreement with the liaison +:manager-quantity: Removes the limit of 30 jobs per manager order +:max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile +:military-color-assigned: Color squad candidates already assigned to other squads in yellow/green + to make them stand out more in the list. + + .. image:: images/tweak-mil-color.png :military-stable-assign: Preserve list order and cursor position when assigning to squad, i.e. stop the rightmost list of the Positions page of the military screen from constantly resetting to the top. -:military-color-assigned: Color squad candidates already assigned to other squads in yellow/green - to make them stand out more in the list. - - .. image:: images/tweak-mil-color.png - -:craft-age-wear: Fixes the behavior of crafted items wearing out over time (bug 6003). - With this tweak, items made from cloth and leather will gain a level of wear every 20 years. - -:adamantine-cloth-wear: Prevents adamantine clothing from wearing out while being worn (bug 6481). -:farm-plot-select: Adds "Select all" and "Deselect all" options to farm plot menus -:import-priority-category: Allows changing the priority of all goods in a - category when discussing an import agreement with the liaison -:manager-quantity: Removes the limit of 30 jobs per manager order -:civ-view-agreement: Fixes overlapping text on the "view agreement" screen :nestbox-color: Fixes the color of built nestboxes -:eggs-fertile: Displays a fertility indicator on nestboxes -:max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile +:shift-8-scroll: Gives Shift-8 (or ``*``) 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. :tradereq-pet-gender: Displays pet genders on the trade request screen fix-armory diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 1c89896e2..2c0cf7d48 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -86,6 +86,7 @@ #include "tweaks/max-wheelbarrow.h" #include "tweaks/military-assign.h" #include "tweaks/nestbox-color.h" +#include "tweaks/shift-8-scroll.h" #include "tweaks/stable-cursor.h" #include "tweaks/tradereq-pet-gender.h" @@ -179,6 +180,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector * input)) + { + if (ui->main.mode != ui_sidebar_mode::Default && + input->count(interface_key::CURSOR_UP_FAST) && + input->count(interface_key::SECONDSCROLL_PAGEDOWN) + ) + { + input->erase(interface_key::CURSOR_UP_FAST); + } + INTERPOSE_NEXT(feed)(input); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(shift_8_scroll_hook, feed); From 83cb7b48f9b202a2dfcfd47db76bc3f3c389a7dd Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 4 Mar 2015 19:03:39 -0500 Subject: [PATCH 2/4] Add "fps-min" tweak and allow onupdate-based tweaks --- NEWS | 1 + Readme.rst | 1 + plugins/tweak/tweak.cpp | 37 ++++++++++++++++++++++++++++++++++ plugins/tweak/tweaks/fps-min.h | 7 +++++++ 4 files changed, 46 insertions(+) create mode 100644 plugins/tweak/tweaks/fps-min.h diff --git a/NEWS b/NEWS index 74e243dcc..5b5be9555 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ DFHack Future New Scripts modtools/reaction-product-trigger: triggers callbacks when products are produced (contrast with when reactions complete) New Tweaks + fps-min: Fixes the in-game minimum FPS setting shift-8-scroll: Gives Shift+8 (or *) priority when scrolling menus, instead of scrolling the map tradereq-pet-gender: Displays pet genders on the trade request screen Removed diff --git a/Readme.rst b/Readme.rst index 0de7eb44e..9d071bd3b 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1310,6 +1310,7 @@ Subcommands that persist until disabled or DF quits: takes for stable-temp to stop updates again when equilibrium is disturbed. :fast-trade: Makes Shift-Down in the Move Goods to Depot and Trade screens select the current item (fully, in case of a stack), and scroll down one line. +:fps-min: Fixes the in-game minimum FPS setting :import-priority-category: Allows changing the priority of all goods in a category when discussing an import agreement with the liaison :manager-quantity: Removes the limit of 30 jobs per manager order diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 2c0cf7d48..76fd25feb 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -81,6 +81,7 @@ #include "tweaks/farm-plot-select.h" #include "tweaks/fast-heat.h" #include "tweaks/fast-trade.h" +#include "tweaks/fps-min.h" #include "tweaks/import-priority-category.h" #include "tweaks/manager-quantity.h" #include "tweaks/max-wheelbarrow.h" @@ -98,6 +99,7 @@ using namespace DFHack; using namespace df::enums; DFHACK_PLUGIN("tweak"); +DFHACK_PLUGIN_IS_ENABLED(is_enabled); REQUIRE_GLOBAL(ui); REQUIRE_GLOBAL(ui_build_selector); @@ -108,11 +110,23 @@ REQUIRE_GLOBAL(world); using namespace DFHack::Gui; +class tweak_onupdate_hookst { +public: + typedef void(*T_callback)(void); + tweak_onupdate_hookst(std::string name_, T_callback cb) + :name(name_), callback(cb), enabled(false) {} + bool enabled; + std::string name; + T_callback callback; +}; static command_result tweak(color_ostream &out, vector & parameters); static std::multimap tweak_hooks; +static std::multimap tweak_onupdate_hooks; #define TWEAK_HOOK(tweak, cls, func) tweak_hooks.insert(std::pair\ (tweak, INTERPOSE_HOOK(cls, func))) +#define TWEAK_ONUPDATE_HOOK(tweak, func) tweak_onupdate_hooks.insert(\ + std::pair(tweak, tweak_onupdate_hookst(#func, func))) DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { @@ -213,6 +227,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector second; + if (hook.enabled) + hook.callback(); + } +} + DFhackCExport command_result plugin_shutdown (color_ostream &out) { return CR_OK; @@ -659,6 +685,17 @@ static command_result enable_tweak(string tweak, color_ostream &out, vector second, parameters); } } + for (auto it = tweak_onupdate_hooks.begin(); it != tweak_onupdate_hooks.end(); ++it) + { + if (it->first == cmd) + { + bool state = (vector_get(parameters, 1) != "disable"); + recognized = true; + tweak_onupdate_hookst hook = it->second; + hook.enabled = state; + out.print("%s tweak %s (%s)\n", state ? "Enabled" : "Disabled", cmd.c_str(), hook.name.c_str()); + } + } if (!recognized) { out.printerr("Unrecognized tweak: %s\n", cmd.c_str()); diff --git a/plugins/tweak/tweaks/fps-min.h b/plugins/tweak/tweaks/fps-min.h new file mode 100644 index 000000000..6dd9eb0aa --- /dev/null +++ b/plugins/tweak/tweaks/fps-min.h @@ -0,0 +1,7 @@ +#include "df/enabler.h" +using df::global::enabler; + +void fps_min_hook() { + if (enabler->fps < 10) + enabler->fps = 10; +} From 8459959124f0def40c38090de866318614b26dce Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 5 Mar 2015 16:29:36 -0500 Subject: [PATCH 3/4] Add fps-min to dfhack.init-example and plugin help --- dfhack.init-example | 1 + plugins/tweak/tweak.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dfhack.init-example b/dfhack.init-example index 1cbeebf97..e7b1931a9 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -179,6 +179,7 @@ tweak import-priority-category # Misc. UI tweaks tweak civ-view-agreement +tweak fps-min tweak max-wheelbarrow tweak tradereq-pet-gender diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 76fd25feb..f5a97f579 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -178,6 +178,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector Date: Sat, 7 Mar 2015 21:10:33 -0500 Subject: [PATCH 4/4] Add "tweak shift-8-scroll" to dfhack.init-example --- dfhack.init-example | 1 + 1 file changed, 1 insertion(+) diff --git a/dfhack.init-example b/dfhack.init-example index e7b1931a9..1bb3f8acf 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -181,6 +181,7 @@ tweak import-priority-category tweak civ-view-agreement tweak fps-min tweak max-wheelbarrow +tweak shift-8-scroll tweak tradereq-pet-gender ###########################