From ffac2f179589cd32fdef9a2c41c608ad0b3d8c80 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 1 Jan 2015 13:47:47 -0500 Subject: [PATCH 1/4] New tweak: "eggs-fertile" --- Readme.html | 5 ++- Readme.rst | 1 + plugins/tweak/tweak.cpp | 5 +++ plugins/tweak/tweaks/eggs-fertile.h | 66 +++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 plugins/tweak/tweaks/eggs-fertile.h diff --git a/Readme.html b/Readme.html index a4ef98057..6ec8651c2 100644 --- a/Readme.html +++ b/Readme.html @@ -2049,7 +2049,10 @@ category when discussing an import agreement with the liaison

 

Fixes overlapping text on the "view agreement" screen

-nestbox-color:

Fixes the color of built nestboxes

+nestbox-color:

Fixes the color of built nestboxes

+ + +eggs-fertile:

Displays a fertility indicator on nestboxes

diff --git a/Readme.rst b/Readme.rst index 15933e0f6..f6ff47c7b 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1329,6 +1329,7 @@ Subcommands that persist until disabled or DF quit: :manager-quantity: Removes the limit of 30 jobs per manager order :civ-view-agreement: Fixes overlapping text on the "view agreement" screen :nestbox-color: Fixes the color of built nestboxes +:eggs-fertile: Displays a fertility indicator on nestboxes fix-armory ---------- diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index d49fbe2da..709a1f484 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -76,6 +76,7 @@ #include "tweaks/advmode-contained.h" #include "tweaks/civ-agreement-ui.h" #include "tweaks/craft-age-wear.h" +#include "tweaks/eggs-fertile.h" #include "tweaks/farm-plot-select.h" #include "tweaks/fast-heat.h" #include "tweaks/fast-trade.h" @@ -147,6 +148,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector \n" @@ -186,6 +189,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector main.mode != ui_sidebar_mode::QueryBuilding && + ui->main.mode != ui_sidebar_mode::BuildingItems) + return NULL; + return virtual_cast(world->selected_building); + } + + DEFINE_VMETHOD_INTERPOSE(void, render, ()) + { + INTERPOSE_NEXT(render)(); + df::building_nest_boxst* nest_box = getNestBox(); + if (nest_box) + { + auto dims = Gui::getDwarfmodeViewDims(); + bool has_eggs = false; + bool fertile = false; + int idx = 0; + for (auto iter = nest_box->contained_items.begin(); + iter != nest_box->contained_items.end(); ++iter) + { + df::item_eggst* egg = virtual_cast((*iter)->item); + if (egg) + { + has_eggs = true; + if (egg->egg_flags.bits.fertile) + fertile = true; + if (ui->main.mode == ui_sidebar_mode::BuildingItems) + { + Screen::paintString( + Screen::Pen(' ', fertile ? COLOR_LIGHTGREEN : COLOR_LIGHTRED), + dims.menu_x2 - (fertile ? 4 : 6), + dims.y1 + idx + 3, + fertile ? "Fert" : "N.Fert" + ); + } + } + ++idx; + } + if (has_eggs && ui->main.mode == ui_sidebar_mode::QueryBuilding) + { + Screen::paintString( + Screen::Pen(' ', fertile ? COLOR_LIGHTGREEN : COLOR_LIGHTRED), + dims.menu_x1 + 1, + dims.y1 + 5, + fertile ? "Eggs Fertile" : "Eggs infertile" + ); + } + } + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(egg_fertile_hook, render); From 47d6e111c8c2dbcab9a51c6a3b2b235e10a133b3 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 1 Jan 2015 14:36:30 -0500 Subject: [PATCH 2/4] New tweak: "max-wheelbarrow" --- Readme.html | 6 +- Readme.rst | 1 + plugins/tweak/tweak.cpp | 9 ++- plugins/tweak/tweaks/max-wheelbarrow.h | 96 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 plugins/tweak/tweaks/max-wheelbarrow.h diff --git a/Readme.html b/Readme.html index 6ec8651c2..6da852c3d 100644 --- a/Readme.html +++ b/Readme.html @@ -2052,7 +2052,11 @@ category when discussing an import agreement with the liaison

nestbox-color:

Fixes the color of built nestboxes

-eggs-fertile:

Displays a fertility indicator on nestboxes

+eggs-fertile:

Displays a fertility indicator on nestboxes

+ + +max-wheelbarrow: + 

Allows assigning more than 3 wheelbarrows to a stockpile

diff --git a/Readme.rst b/Readme.rst index f6ff47c7b..187b0fc88 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1330,6 +1330,7 @@ Subcommands that persist until disabled or DF quit: :civ-view-agreement: Fixes overlapping text on the "view agreement" screen :nestbox-color: Fixes the color of built nestboxes :eggs-fertile: Displays a fertility indicator on nestboxes +:max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile fix-armory ---------- diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 709a1f484..3ecd81299 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -13,6 +13,7 @@ #include "modules/Job.h" #include "modules/Materials.h" #include "modules/MapCache.h" +#include "modules/Buildings.h" #include "MiscUtils.h" @@ -82,6 +83,7 @@ #include "tweaks/fast-trade.h" #include "tweaks/import-priority-category.h" #include "tweaks/manager-quantity.h" +#include "tweaks/max-wheelbarrow.h" #include "tweaks/military-assign.h" #include "tweaks/nestbox-color.h" #include "tweaks/stable-cursor.h" @@ -148,7 +150,7 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector > ret; + return ret; + } + + df::building_stockpilest* getStockpile() + { + if (ui->main.mode != ui_sidebar_mode::QueryBuilding) + return NULL; + return virtual_cast(world->selected_building); + } + + DEFINE_VMETHOD_INTERPOSE(void, render, ()) + { + INTERPOSE_NEXT(render)(); + df::building_stockpilest* stockpile = getStockpile(); + if (stockpile && in_wheelbarrow_entry) + { + auto dims = Gui::getDwarfmodeViewDims(); + Screen::paintString(Screen::Pen(' ', COLOR_LIGHTCYAN), + dims.menu_x1 + 22, dims.y1 + 6, wheelbarrow_entry + "_"); + } + } + + DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set* input)) + { + df::building_stockpilest* stockpile = getStockpile(); + bool handled = false; + if (stockpile) + { + auto dims = Gui::getDwarfmodeViewDims(); + handled = true; + if (!in_wheelbarrow_entry && + input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW)) + { + in_wheelbarrow_entry = true; + std::stringstream tmp; + tmp << stockpile->max_wheelbarrows; + tmp >> wheelbarrow_entry; + } + else if (in_wheelbarrow_entry) + { + if (input->count(df::interface_key::SELECT) || + input->count(df::interface_key::LEAVESCREEN) || + input->count(df::interface_key::LEAVESCREEN_ALL) || + input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW)) + { + in_wheelbarrow_entry = false; + stockpile->max_wheelbarrows = std::min(wheelbarrow_count(), + Buildings::countExtentTiles(&stockpile->room)); + } + else if (input->count(df::interface_key::STRING_A000) && + wheelbarrow_entry.size()) + { + wheelbarrow_entry.resize(wheelbarrow_entry.size() - 1); + } + else + { + for (auto iter = input->begin(); iter != input->end(); ++iter) + { + df::interface_key key = *iter; + if (key >= Screen::charToKey('0') && key <= Screen::charToKey('9') && + wheelbarrow_entry.size() < 3) + { + wheelbarrow_entry.push_back(Screen::keyToChar(key)); + } + } + } + } + else + handled = false; + } + if (!handled) + INTERPOSE_NEXT(feed)(input); + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(max_wheelbarrow_hook, render); +IMPLEMENT_VMETHOD_INTERPOSE(max_wheelbarrow_hook, feed); From cc22c034abd10dca365116a8a9c2f2a4ceaa5af0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 1 Jan 2015 14:38:14 -0500 Subject: [PATCH 3/4] Update NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 1b9ec3f8b..8c1ef4a91 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ DFHack Future Fixes New Plugins New Scripts + New tweaks: + eggs-fertile: Displays an egg fertility indicator on nestboxes + max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile Misc Improvements DFHack 0.40.19-r1 From cea32a335c1580c086f9f6f6d5a350d74a090d19 Mon Sep 17 00:00:00 2001 From: Lethosor Date: Thu, 1 Jan 2015 20:20:11 -0500 Subject: [PATCH 4/4] Add `tweak max-wheelbarrow` to dfhack.init-example --- dfhack.init-example | 1 + 1 file changed, 1 insertion(+) diff --git a/dfhack.init-example b/dfhack.init-example index c1cd1ac86..32a84e067 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -174,6 +174,7 @@ tweak import-priority-category # Misc. UI tweaks tweak civ-view-agreement +tweak max-wheelbarrow ########################### # Globally acting plugins #