diff --git a/NEWS b/NEWS index 6e8c5fe66..6b2c23bb2 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ DFHack Future - EventManager: deals with frame_counter getting reset properly now. - modtools/item-trigger: fixed equip/unequip bug and corrected minor documentation error - teleport: Updated with proper argument handling and proper unit-at-destination handling. + - autotrade: Removed the newly obsolete "Mark all" functionality. + - search: Adapts to the new trade screen column width + - tweak fast-trade: Switching the fast-trade keybinding to Shift-Up/Shift-Down, due to Select All conflict DFHack 0.40.14-r1 Internals: diff --git a/Readme.html b/Readme.html index 32dedbdbb..7b21d2b83 100644 --- a/Readme.html +++ b/Readme.html @@ -1969,7 +1969,7 @@ 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 +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.

@@ -3342,12 +3342,14 @@ enabled materials, you should be able to place complex constructions more conven

Stockpile Automation

-

Enable the automelt plugin in your dfhack.init with:

+

Enable the automelt or autotrade plugins in your dfhack.init with:

 enable automelt
+enable autotrade
 
-

When querying a stockpile an option will appear to toggle automelt for this stockpile. -Any items placed in this stockpile will be designated to be melted.

+

When querying a stockpile, options will appear to toggle automelt and/or autotrade for this stockpile. +When automelt is enabled for a stockpile, any meltable items placed in it will be designated to be melted. +When autotrade is enabled for a stockpile, any items placed in it will be designated to be taken to the Trade Depot whenever merchants are on the map.

Track Stop Menu

diff --git a/Readme.rst b/Readme.rst index 818c6fa6d..0e637d051 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1266,7 +1266,7 @@ 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 +: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. :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 @@ -2709,12 +2709,14 @@ enabled materials, you should be able to place complex constructions more conven Stockpile Automation ==================== -Enable the automelt plugin in your dfhack.init with:: +Enable the automelt or autotrade plugins in your dfhack.init with:: enable automelt + enable autotrade -When querying a stockpile an option will appear to toggle automelt for this stockpile. -Any items placed in this stockpile will be designated to be melted. +When querying a stockpile, options will appear to toggle automelt and/or autotrade for this stockpile. +When automelt is enabled for a stockpile, any meltable items placed in it will be designated to be melted. +When autotrade is enabled for a stockpile, any items placed in it will be designated to be taken to the Trade Depot whenever merchants are on the map. Track Stop Menu =============== diff --git a/plugins/autotrade.cpp b/plugins/autotrade.cpp index eff1b5d64..f3922b96a 100644 --- a/plugins/autotrade.cpp +++ b/plugins/autotrade.cpp @@ -25,7 +25,6 @@ using df::global::ui; using df::building_stockpilest; DFHACK_PLUGIN("autotrade"); -#define PLUGIN_VERSION 0.4 static const string PERSISTENCE_KEY = "autotrade/stockpiles"; @@ -445,99 +444,6 @@ struct trade_hook : public df::viewscreen_dwarfmodest IMPLEMENT_VMETHOD_INTERPOSE(trade_hook, feed); IMPLEMENT_VMETHOD_INTERPOSE(trade_hook, render); -struct tradeview_hook : public df::viewscreen_tradegoodsst -{ - typedef df::viewscreen_tradegoodsst interpose_base; - - bool handleInput(set *input) - { - if (input->count(interface_key::CUSTOM_M)) - { - for (int i = 0; i < trader_selected.size(); i++) - { - // Only mark containers, not their contents. - // Granted, this behaves poorly with the search plugin... - trader_selected[i] = !trader_items[i]->flags.bits.in_inventory; - } - } - else if (input->count(interface_key::CUSTOM_U)) - { - for (int i = 0; i < trader_selected.size(); i++) - { - trader_selected[i] = 0; - } - } - else if (input->count(interface_key::CUSTOM_SHIFT_M)) - { - for (int i = 0; i < broker_selected.size(); i++) - { - // Only mark containers, not their contents. - broker_selected[i] = !broker_items[i]->flags.bits.in_inventory; - } - } - else if (input->count(interface_key::CUSTOM_SHIFT_U)) - { - for (int i = 0; i < broker_selected.size(); i++) - { - broker_selected[i] = 0; - } - } - else - { - return false; - } - - return true; - } - - DEFINE_VMETHOD_INTERPOSE(void, feed, (set *input)) - { - if (!handleInput(input)) - INTERPOSE_NEXT(feed)(input); - } - - DEFINE_VMETHOD_INTERPOSE(void, render, ()) - { - INTERPOSE_NEXT(render)(); - - if (counteroffer.size() > 0) - { - // The merchant is proposing a counteroffer, - // so there is nothing to mark. - return; - } - - // Insert into the blank line between trade items and standard keys. - // The blank line at the bottom is taken by the search plugin. - auto dim = Screen::getWindowSize(); - int y = dim.y - 5; - - int x = 2; - OutputHotkeyString(x, y, "Mark all, ", "m", false, x, COLOR_WHITE, COLOR_LIGHTRED); - OutputHotkeyString(x, y, "Unmark all", "u", false, x, COLOR_WHITE, COLOR_LIGHTRED); - - x = 42; - OutputHotkeyString(x, y, "Mark all, ", "M", false, x, COLOR_WHITE, COLOR_LIGHTRED); - OutputHotkeyString(x, y, "Unmark all", "U", false, x, COLOR_WHITE, COLOR_LIGHTRED); - } -}; - -IMPLEMENT_VMETHOD_INTERPOSE(tradeview_hook, feed); -IMPLEMENT_VMETHOD_INTERPOSE(tradeview_hook, render); - - -static command_result autotrade_cmd(color_ostream &out, vector & parameters) -{ - if (!parameters.empty()) - { - if (parameters.size() == 1 && toLower(parameters[0])[0] == 'v') - { - out << "Autotrade" << endl << "Version: " << PLUGIN_VERSION << endl; - } - } - - return CR_OK; -} DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { @@ -568,9 +474,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) monitor.reset(); if (!INTERPOSE_HOOK(trade_hook, feed).apply(enable) || - !INTERPOSE_HOOK(trade_hook, render).apply(enable) || - !INTERPOSE_HOOK(tradeview_hook, feed).apply(enable) || - !INTERPOSE_HOOK(tradeview_hook, render).apply(enable)) + !INTERPOSE_HOOK(trade_hook, render).apply(enable)) return CR_FAILURE; is_enabled = enable; @@ -581,11 +485,6 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { - commands.push_back( - PluginCommand( - "autotrade", "Automatically send items in marked stockpiles to trade depot, when trading is possible.", - autotrade_cmd, false, "Run 'autotrade version' to query the plugin version.\n")); - return CR_OK; } diff --git a/plugins/search.cpp b/plugins/search.cpp index 90a146c32..e25b36fe1 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1093,8 +1093,7 @@ public: { int32_t x = 2; int32_t y = gps->dimy - 3; - make_text_dim(2, 37, y); - make_text_dim(42, gps->dimx-2, y); + make_text_dim(2, gps->dimx-2, y); OutputString(COLOR_LIGHTRED, x, y, string(1, select_key + 'A' - 'a')); OutputString(COLOR_WHITE, x, y, ": Clear search to trade "); } @@ -1138,14 +1137,13 @@ public: return; } - print_search_option(42, -1); + int32_t x = gps->dimx / 2 + 2; + print_search_option(x, -1); if (!search_string.empty()) { - int32_t x = 42; int32_t y = gps->dimy - 3; - make_text_dim(2, 37, y); - make_text_dim(42, gps->dimx-2, y); + make_text_dim(2, gps->dimx-2, y); OutputString(COLOR_LIGHTRED, x, y, string(1, select_key + 'A' - 'a')); OutputString(COLOR_WHITE, x, y, ": Clear search to trade "); } diff --git a/plugins/tweak/tweaks/fast-trade.h b/plugins/tweak/tweaks/fast-trade.h index 66e1c9637..d0bcc9812 100644 --- a/plugins/tweak/tweaks/fast-trade.h +++ b/plugins/tweak/tweaks/fast-trade.h @@ -5,13 +5,20 @@ struct fast_trade_assign_hook : df::viewscreen_layer_assigntradest { DEFINE_VMETHOD_INTERPOSE(void, feed, (set *input)) { - if (layer_objects[1]->active && input->count(interface_key::SELECT_ALL)) + if (layer_objects[1]->active && input->count(interface_key::CURSOR_DOWN_FAST)) { set tmp; tmp.insert(interface_key::SELECT); INTERPOSE_NEXT(feed)(&tmp); tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN); INTERPOSE_NEXT(feed)(&tmp); } + else if (layer_objects[1]->active && input->count(interface_key::CURSOR_UP_FAST)) + { + set tmp; tmp.insert(interface_key::STANDARDSCROLL_UP); + INTERPOSE_NEXT(feed)(&tmp); + tmp.clear(); tmp.insert(interface_key::SELECT); + INTERPOSE_NEXT(feed)(&tmp); + } else INTERPOSE_NEXT(feed)(input); } @@ -25,7 +32,7 @@ struct fast_trade_select_hook : df::viewscreen_tradegoodsst { DEFINE_VMETHOD_INTERPOSE(void, feed, (set *input)) { if (!(is_unloading || !has_traders || in_edit_count) - && input->count(interface_key::SELECT_ALL)) + && input->count(interface_key::CURSOR_DOWN_FAST)) { set tmp; tmp.insert(interface_key::SELECT); INTERPOSE_NEXT(feed)(&tmp); @@ -34,6 +41,16 @@ struct fast_trade_select_hook : df::viewscreen_tradegoodsst { tmp.clear(); tmp.insert(interface_key::STANDARDSCROLL_DOWN); INTERPOSE_NEXT(feed)(&tmp); } + else if (!(is_unloading || !has_traders || in_edit_count) + && input->count(interface_key::CURSOR_UP_FAST)) + { + set tmp; tmp.insert(interface_key::STANDARDSCROLL_UP); + INTERPOSE_NEXT(feed)(&tmp); + tmp.clear(); tmp.insert(interface_key::SELECT); + INTERPOSE_NEXT(feed)(&tmp); + if (in_edit_count) + INTERPOSE_NEXT(feed)(&tmp); + } else INTERPOSE_NEXT(feed)(input); }