From 6f77372367d2227f60f04efffc6977be9685418f Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Tue, 19 Aug 2014 14:19:13 -0600 Subject: [PATCH] No longer overwrites stockpile links The new lines added to the stockpile 'q' menu are usually drawn at the bottom, where the last few Give/Take links are written. Now, they notice when they would overwrite one of those links, and move somewhere else. The 'Done' line can now be overwritten by stockflow, but that hint isn't necessary for experienced players. --- plugins/autotrade.cpp | 9 +++++++++ plugins/stockflow.cpp | 8 ++++++++ plugins/stocks.cpp | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/plugins/autotrade.cpp b/plugins/autotrade.cpp index b2cc4cdc2..8fbc75b89 100644 --- a/plugins/autotrade.cpp +++ b/plugins/autotrade.cpp @@ -422,6 +422,15 @@ struct trade_hook : public df::viewscreen_dwarfmodest int left_margin = dims.menu_x1 + 1; int x = left_margin; int y = dims.y2 - 4; + + int links = 0; + links += sp->links.give_to_pile.size(); + links += sp->links.take_from_pile.size(); + links += sp->links.give_to_workshop.size(); + links += sp->links.take_from_workshop.size(); + if (links + 12 >= y) + y += 4; + OutputToggleString(x, y, "Auto trade", "T", monitor.isMonitored(sp), true, left_margin, COLOR_WHITE, COLOR_LIGHTRED); } }; diff --git a/plugins/stockflow.cpp b/plugins/stockflow.cpp index 5222d5ec9..257680682 100644 --- a/plugins/stockflow.cpp +++ b/plugins/stockflow.cpp @@ -208,6 +208,14 @@ public: int x = left_margin; int y = dims.y2 - 3; + int links = 0; + links += sp->links.give_to_pile.size(); + links += sp->links.take_from_pile.size(); + links += sp->links.give_to_workshop.size(); + links += sp->links.take_from_workshop.size(); + if (links + 12 >= y) + y += 1; + OutputHotkeyString(x, y, current_job, "j", true, left_margin, COLOR_WHITE, COLOR_LIGHTRED); if (*current_trigger) OutputHotkeyString(x, y, current_trigger, " J", true, left_margin, COLOR_WHITE, COLOR_LIGHTRED); diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index 356cc44e7..64e4d4dba 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -1377,6 +1377,14 @@ struct stocks_stockpile_hook : public df::viewscreen_dwarfmodest int left_margin = dims.menu_x1 + 1; int x = left_margin; int y = dims.y2 - 5; + + int links = 0; + links += sp->links.give_to_pile.size(); + links += sp->links.take_from_pile.size(); + links += sp->links.give_to_workshop.size(); + links += sp->links.take_from_workshop.size(); + if (links + 12 >= y) + y = 3; OutputHotkeyString(x, y, "Show Inventory", "i", true, left_margin, COLOR_WHITE, COLOR_LIGHTRED); }