Implement the common suggestion of Shift-Enter in trade screens.

develop
Alexander Gavrilov 2012-09-28 13:32:41 +04:00
parent 7e0365857d
commit bd7cd690aa
5 changed files with 62 additions and 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 in advmode. The issue is that the screen tries to force you to select
the contents separately from the container. This forcefully skips child the contents separately from the container. This forcefully skips child
reagents. 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 Mode switch and reclaim
======================= =======================

@ -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 the contents separately from the container. This forcefully skips child
reagents.</td> reagents.</td>
</tr> </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> </tbody>
</table> </table>
</div> </div>

@ -45,6 +45,7 @@ keybinding add Shift-R "job-material RHYOLITE"
keybinding add Shift-I "job-material CINNABAR" keybinding add Shift-I "job-material CINNABAR"
keybinding add Shift-B "job-material COBALTITE" keybinding add Shift-B "job-material COBALTITE"
keybinding add Shift-O "job-material OBSIDIAN" keybinding add Shift-O "job-material OBSIDIAN"
keybinding add Shift-T "job-material ORTHOCLASE"
keybinding add Shift-G "job-material GLASS_GREEN" keybinding add Shift-G "job-material GLASS_GREEN"
# browse linked mechanisms # browse linked mechanisms
@ -90,3 +91,7 @@ tweak fix-dimensions
# make reactions requiring containers usable in advmode - the issue is # make reactions requiring containers usable in advmode - the issue is
# that the screen asks for those reagents to be selected directly # that the screen asks for those reagents to be selected directly
tweak advmode-contained 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

@ -523,6 +523,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
events->insert(interface_key::LEAVESCREEN); events->insert(interface_key::LEAVESCREEN);
parent->feed(events); parent->feed(events);
events->clear();
} }
return; return;
} }

@ -43,6 +43,8 @@
#include "df/reaction.h" #include "df/reaction.h"
#include "df/reaction_reagent_itemst.h" #include "df/reaction_reagent_itemst.h"
#include "df/reaction_reagent_flags.h" #include "df/reaction_reagent_flags.h"
#include "df/viewscreen_layer_assigntradest.h"
#include "df/viewscreen_tradegoodsst.h"
#include <stdlib.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" " 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" " that the screen tries to force you to select the contents separately\n"
" from the container. This forcefully skips child reagents.\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; return CR_OK;
} }
@ -494,6 +499,47 @@ struct advmode_contained_hook : df::viewscreen_layer_unit_actionst {
IMPLEMENT_VMETHOD_INTERPOSE(advmode_contained_hook, feed); 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> &parameters) static void enable_hook(color_ostream &out, VMethodInterposeLinkBase &hook, vector <string> &parameters)
{ {
if (vector_get(parameters, 1) == "disable") if (vector_get(parameters, 1) == "disable")
@ -653,6 +699,11 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
{ {
enable_hook(out, INTERPOSE_HOOK(advmode_contained_hook, feed), parameters); 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 else
return CR_WRONG_USAGE; return CR_WRONG_USAGE;