Merge remote-tracking branch 'eswald/tradescreen' into develop

Conflicts:
	NEWS
develop
expwnent 2014-11-09 00:42:50 -05:00
commit 1b0a2ecb8a
6 changed files with 39 additions and 118 deletions

@ -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:

@ -1969,7 +1969,7 @@ the contents separately from the container. This forcefully skips child
reagents.</p>
</td>
</tr>
<tr class="field"><th class="field-name">fast-trade:</th><td class="field-body"><p class="first">Makes Shift-Enter in the Move Goods to Depot and Trade screens select
<tr class="field"><th class="field-name">fast-trade:</th><td class="field-body"><p class="first">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.</p>
</td>
</tr>
@ -3342,12 +3342,14 @@ enabled materials, you should be able to place complex constructions more conven
</div>
<div class="section" id="stockpile-automation">
<h2><a class="toc-backref" href="#id161">Stockpile Automation</a></h2>
<p>Enable the automelt plugin in your dfhack.init with:</p>
<p>Enable the automelt or autotrade plugins in your dfhack.init with:</p>
<pre class="literal-block">
enable automelt
enable autotrade
</pre>
<p>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.</p>
<p>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.</p>
</div>
<div class="section" id="track-stop-menu">
<h2><a class="toc-backref" href="#id162">Track Stop Menu</a></h2>

@ -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
===============

@ -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<df::interface_key> *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<df::interface_key> *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 <string> & 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 <PluginCommand> &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;
}

@ -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 ");
}

@ -5,13 +5,20 @@ struct fast_trade_assign_hook : df::viewscreen_layer_assigntradest {
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *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<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 if (layer_objects[1]->active && input->count(interface_key::CURSOR_UP_FAST))
{
set<df::interface_key> 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<df::interface_key> *input))
{
if (!(is_unloading || !has_traders || in_edit_count)
&& input->count(interface_key::SELECT_ALL))
&& input->count(interface_key::CURSOR_DOWN_FAST))
{
set<df::interface_key> 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<df::interface_key> 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);
}