diff options
| -rw-r--r-- | README.rst | 3 | ||||
| -rw-r--r-- | Readme.html | 3 | ||||
| -rw-r--r-- | dfhack.init-example | 5 | ||||
| -rw-r--r-- | plugins/manipulator.cpp | 1 | ||||
| -rw-r--r-- | plugins/tweak.cpp | 51 |
5 files changed, 62 insertions, 1 deletions
@@ -1013,7 +1013,8 @@ Subcommands that persist until disabled or DF quit: 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-Enter in the Move Goods to Depot and Trade screens select + the current item (fully, in case of a stack), and scroll down one line. Mode switch and reclaim ======================= diff --git a/Readme.html b/Readme.html index 3610ecd8..6155b72c 100644 --- a/Readme.html +++ b/Readme.html @@ -1753,6 +1753,9 @@ 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.</td> </tr> +<tr class="field"><th class="field-name">fast-trade:</th><td class="field-body">Makes Shift-Enter in the Move Goods to Depot and Trade screens select +the current item (fully, in case of a stack), and scroll down one line.</td> +</tr> </tbody> </table> </div> diff --git a/dfhack.init-example b/dfhack.init-example index 0bf34460..8a3ec8f2 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -45,6 +45,7 @@ keybinding add Shift-R "job-material RHYOLITE" keybinding add Shift-I "job-material CINNABAR" keybinding add Shift-B "job-material COBALTITE" keybinding add Shift-O "job-material OBSIDIAN" +keybinding add Shift-T "job-material ORTHOCLASE" keybinding add Shift-G "job-material GLASS_GREEN" # browse linked mechanisms @@ -90,3 +91,7 @@ tweak fix-dimensions # make reactions requiring containers usable in advmode - the issue is # that the screen asks for those reagents to be selected directly tweak advmode-contained + +# support Shift-Enter in Trade and Move Goods to Depot screens for faster +# selection; it selects the current item or stack and scrolls down one line +tweak fast-trade diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 0b0b99d4..f3c6664a 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -523,6 +523,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events) { events->insert(interface_key::LEAVESCREEN); parent->feed(events); + events->clear(); } return; } diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index fb286e0d..6d0591d1 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -43,6 +43,8 @@ #include "df/reaction.h" #include "df/reaction_reagent_itemst.h" #include "df/reaction_reagent_flags.h" +#include "df/viewscreen_layer_assigntradest.h" +#include "df/viewscreen_tradegoodsst.h" #include <stdlib.h> @@ -109,6 +111,9 @@ 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 fast-trade [disable]\n" + " Makes Shift-Enter in the Move Goods to Depot and Trade screens select\n" + " the current item (fully, in case of a stack), and scroll down one line.\n" )); return CR_OK; } @@ -494,6 +499,47 @@ struct advmode_contained_hook : df::viewscreen_layer_unit_actionst { IMPLEMENT_VMETHOD_INTERPOSE(advmode_contained_hook, feed); +struct fast_trade_assign_hook : df::viewscreen_layer_assigntradest { + typedef df::viewscreen_layer_assigntradest interpose_base; + + DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input)) + { + if (layer_objects[1]->active && input->count(interface_key::SELECT_ALL)) + { + set<df::interface_key> tmp; tmp.insert(interface_key::SELECT); + INTERPOSE_NEXT(feed)(&tmp); + tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN); + INTERPOSE_NEXT(feed)(&tmp); + } + else + INTERPOSE_NEXT(feed)(input); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(fast_trade_assign_hook, feed); + +struct fast_trade_select_hook : df::viewscreen_tradegoodsst { + typedef df::viewscreen_tradegoodsst interpose_base; + + DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input)) + { + if (!(is_unloading || !has_traders || in_edit_count) + && input->count(interface_key::SELECT_ALL)) + { + set<df::interface_key> tmp; tmp.insert(interface_key::SELECT); + INTERPOSE_NEXT(feed)(&tmp); + if (in_edit_count) + INTERPOSE_NEXT(feed)(&tmp); + tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN); + INTERPOSE_NEXT(feed)(&tmp); + } + else + INTERPOSE_NEXT(feed)(input); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(fast_trade_select_hook, feed); + static void enable_hook(color_ostream &out, VMethodInterposeLinkBase &hook, vector <string> ¶meters) { if (vector_get(parameters, 1) == "disable") @@ -653,6 +699,11 @@ static command_result tweak(color_ostream &out, vector <string> ¶meters) { enable_hook(out, INTERPOSE_HOOK(advmode_contained_hook, feed), parameters); } + else if (cmd == "fast-trade") + { + enable_hook(out, INTERPOSE_HOOK(fast_trade_assign_hook, feed), parameters); + enable_hook(out, INTERPOSE_HOOK(fast_trade_select_hook, feed), parameters); + } else return CR_WRONG_USAGE; |
