From 999d265d503b0daabab3d978d2946bccaf66c74a Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 27 Sep 2014 18:14:25 -0400 Subject: [PATCH] New tweak: import-priority-category --- plugins/tweak/tweak.cpp | 8 ++++ .../tweak/tweaks/import-priority-category.h | 39 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 plugins/tweak/tweaks/import-priority-category.h diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 2cdec0668..b2ab8758b 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -17,6 +17,7 @@ #include "DataDefs.h" #include +#include "../uicommon.h" #include "df/ui.h" #include "df/world.h" #include "df/squad.h" @@ -75,6 +76,7 @@ #include "tweaks/craft-age-wear.h" #include "tweaks/fast-heat.h" #include "tweaks/fast-trade.h" +#include "tweaks/import-priority-category.h" #include "tweaks/manager-quantity.h" #include "tweaks/military-assign.h" #include "tweaks/stable-cursor.h" @@ -153,6 +155,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector * input)) + { + if (input->count(interface_key::CURSOR_RIGHT_FAST) || + input->count(interface_key::CURSOR_LEFT_FAST)) + { + int delta = 0 + input->count(interface_key::CURSOR_RIGHT_FAST) + - input->count(interface_key::CURSOR_LEFT_FAST); + vector &cur_priorities = meeting->sell_requests->priority[type_categories[type_idx]]; + for (size_t i = 0; i < cur_priorities.size(); i++) + { + cur_priorities[i] += delta; + if (cur_priorities[i] > 4) + cur_priorities[i] = 4; + if (cur_priorities[i] < 0) + cur_priorities[i] = 0; + } + } + INTERPOSE_NEXT(feed)(input); + } + DEFINE_VMETHOD_INTERPOSE(void, render, ()) + { + INTERPOSE_NEXT(render)(); + int x = 45, y = 23; + OutputString(COLOR_LIGHTRED, x, y, "Shift+Left/Right"); + OutputString(COLOR_GREY, x, y, ": Adjust category"); + } +}; +IMPLEMENT_VMETHOD_INTERPOSE(takerequest_hook, feed); +IMPLEMENT_VMETHOD_INTERPOSE(takerequest_hook, render);