From aaa8a829d18a5ffeaab748bdc9f4d4fceaa070ce Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Thu, 4 Sep 2014 21:08:46 -0600 Subject: [PATCH 1/2] Removing new trade hotkeys while a counteroffer is displayed. Fixes http://www.bay12forums.com/smf/index.php?topic=126076.1140 It's tempting to use has_offer for this effect, but that flag remains true after hitting Enter to consider the offer. Relies on a structure update: https://github.com/DFHack/df-structures/pull/18 --- plugins/autotrade.cpp | 7 +++++++ plugins/search.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/plugins/autotrade.cpp b/plugins/autotrade.cpp index c7b1b6ecb..898e96493 100644 --- a/plugins/autotrade.cpp +++ b/plugins/autotrade.cpp @@ -481,6 +481,13 @@ struct tradeview_hook : public df::viewscreen_tradegoodsst { 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(); diff --git a/plugins/search.cpp b/plugins/search.cpp index 18586657b..dcf36809f 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1074,6 +1074,14 @@ class trade_search_merc : public trade_search_base public: virtual void render() const { + if (viewscreen->counteroffer.size() > 0) + { + // The merchant is proposing a counteroffer. + // Not only is there nothing to search, + // but the native hotkeys are where we normally write. + return; + } + print_search_option(2, -1); if (!search_string.empty()) @@ -1116,6 +1124,14 @@ class trade_search_fort : public trade_search_base public: virtual void render() const { + if (viewscreen->counteroffer.size() > 0) + { + // The merchant is proposing a counteroffer. + // Not only is there nothing to search, + // but the native hotkeys are where we normally write. + return; + } + print_search_option(42, -1); if (!search_string.empty()) From 714347925398f46626395f78e986872446e08864 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Thu, 4 Sep 2014 23:28:59 -0600 Subject: [PATCH 2/2] Moving trade screen search dimming to the proper row. Unfortunately, this now means it hits one of the search clear lines when both are active. --- plugins/search.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/search.cpp b/plugins/search.cpp index dcf36809f..0309e4861 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -408,7 +408,7 @@ protected: //bool redo_search; string search_string; -private: +protected: int *cursor_pos; char select_key; bool valid; @@ -1086,11 +1086,12 @@ public: if (!search_string.empty()) { - make_text_dim(2, 37, 22); - make_text_dim(42, gps->dimx-2, 22); int32_t x = 2; int32_t y = gps->dimy - 3; - OutputString(COLOR_YELLOW, x, y, "Note: Clear search to trade"); + make_text_dim(2, 37, y); + make_text_dim(42, gps->dimx-2, y); + OutputString(COLOR_LIGHTRED, x, y, string(1, select_key + 'A' - 'a')); + OutputString(COLOR_WHITE, x, y, ": Clear search to trade "); } } @@ -1136,11 +1137,12 @@ public: if (!search_string.empty()) { - make_text_dim(2, 37, 22); - make_text_dim(42, gps->dimx-2, 22); int32_t x = 42; int32_t y = gps->dimy - 3; - OutputString(COLOR_YELLOW, x, y, "Note: Clear search to trade"); + make_text_dim(2, 37, y); + make_text_dim(42, gps->dimx-2, y); + OutputString(COLOR_LIGHTRED, x, y, string(1, select_key + 'A' - 'a')); + OutputString(COLOR_WHITE, x, y, ": Clear search to trade "); } }