Skip to content

Commit

Permalink
Merge pull request DFHack#298 from eswald/stockpile-lines
Browse files Browse the repository at this point in the history
Stockpile lines
  • Loading branch information
quietust committed Aug 28, 2014
2 parents 1de9405 + 6f77372 commit 8bfc0e9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
13 changes: 11 additions & 2 deletions plugins/autotrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,17 @@ struct trade_hook : public df::viewscreen_dwarfmodest
auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1;
int x = left_margin;
int y = 24;
OutputToggleString(x, y, "Auto trade", "Shift-T", monitor.isMonitored(sp), true, 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);
}
};

Expand Down
10 changes: 9 additions & 1 deletion plugins/stockflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,15 @@ class LuaHelper {
auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1;
int x = left_margin;
int y = 14;
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)
Expand Down
14 changes: 11 additions & 3 deletions plugins/stocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,9 +1376,17 @@ struct stocks_stockpile_hook : public df::viewscreen_dwarfmodest
auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1;
int x = left_margin;
int y = 23;

OutputHotkeyString(x, y, "Show Inventory", "i", true, 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);
}
};

Expand Down
7 changes: 4 additions & 3 deletions plugins/uicommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ void OutputFilterString(int &x, int &y, const char *text, const char *hotkey, bo
OutputString((state) ? COLOR_WHITE : COLOR_GREY, x, y, text, newline, left_margin);
}

void OutputToggleString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = true, int left_margin = 0, int8_t color = COLOR_WHITE)
void OutputToggleString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = true,
int left_margin = 0, int8_t color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN)
{
OutputHotkeyString(x, y, text, hotkey);
OutputString(COLOR_WHITE, x, y, ": ");
OutputHotkeyString(x, y, text, hotkey, false, 0, color, hotkey_color);
OutputString(color, x, y, ": ");
if (state)
OutputString(COLOR_GREEN, x, y, "On", newline, left_margin);
else
Expand Down

0 comments on commit 8bfc0e9

Please sign in to comment.