New tweak: "eggs-fertile"

develop
lethosor 2015-01-01 13:47:47 -05:00
parent 5fc8a1f51f
commit ffac2f1795
4 changed files with 76 additions and 1 deletions

@ -2049,7 +2049,10 @@ category when discussing an import agreement with the liaison</p>
<tr class="field"><td>&nbsp;</td><td class="field-body"><p class="first">Fixes overlapping text on the &quot;view agreement&quot; screen</p> <tr class="field"><td>&nbsp;</td><td class="field-body"><p class="first">Fixes overlapping text on the &quot;view agreement&quot; screen</p>
</td> </td>
</tr> </tr>
<tr class="field"><th class="field-name">nestbox-color:</th><td class="field-body"><p class="first last">Fixes the color of built nestboxes</p> <tr class="field"><th class="field-name">nestbox-color:</th><td class="field-body"><p class="first">Fixes the color of built nestboxes</p>
</td>
</tr>
<tr class="field"><th class="field-name">eggs-fertile:</th><td class="field-body"><p class="first last">Displays a fertility indicator on nestboxes</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>

@ -1329,6 +1329,7 @@ Subcommands that persist until disabled or DF quit:
:manager-quantity: Removes the limit of 30 jobs per manager order :manager-quantity: Removes the limit of 30 jobs per manager order
:civ-view-agreement: Fixes overlapping text on the "view agreement" screen :civ-view-agreement: 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
fix-armory fix-armory
---------- ----------

@ -76,6 +76,7 @@
#include "tweaks/advmode-contained.h" #include "tweaks/advmode-contained.h"
#include "tweaks/civ-agreement-ui.h" #include "tweaks/civ-agreement-ui.h"
#include "tweaks/craft-age-wear.h" #include "tweaks/craft-age-wear.h"
#include "tweaks/eggs-fertile.h"
#include "tweaks/farm-plot-select.h" #include "tweaks/farm-plot-select.h"
#include "tweaks/fast-heat.h" #include "tweaks/fast-heat.h"
#include "tweaks/fast-trade.h" #include "tweaks/fast-trade.h"
@ -147,6 +148,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes overlapping text on the \"view agreement\" screen\n" " Fixes overlapping text on the \"view agreement\" screen\n"
" tweak craft-age-wear [disable]\n" " tweak craft-age-wear [disable]\n"
" Makes cloth and leather items wear out at the correct rate (bug 6003).\n" " Makes cloth and leather items wear out at the correct rate (bug 6003).\n"
" tweak eggs-fertile\n"
" Displays a fertile/infertile indicator on nestboxes\n"
" tweak farm-plot-select [disable]\n" " tweak farm-plot-select [disable]\n"
" Adds \"Select all\" and \"Deselect all\" options to farm plot menus\n" " Adds \"Select all\" and \"Deselect all\" options to farm plot menus\n"
" tweak fast-heat <max-ticks>\n" " tweak fast-heat <max-ticks>\n"
@ -186,6 +189,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("craft-age-wear", craft_age_wear_hook, ageItem); TWEAK_HOOK("craft-age-wear", craft_age_wear_hook, ageItem);
TWEAK_HOOK("eggs-fertile", egg_fertile_hook, render);
TWEAK_HOOK("farm-plot-select", farm_select_hook, feed); TWEAK_HOOK("farm-plot-select", farm_select_hook, feed);
TWEAK_HOOK("farm-plot-select", farm_select_hook, render); TWEAK_HOOK("farm-plot-select", farm_select_hook, render);

@ -0,0 +1,66 @@
#include "df/building_nest_boxst.h"
#include "df/item_eggst.h"
#include "df/viewscreen_dwarfmodest.h"
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::ui;
struct egg_fertile_hook : df::viewscreen_dwarfmodest {
typedef df::viewscreen_dwarfmodest interpose_base;
df::building_nest_boxst* getNestBox()
{
if (ui->main.mode != ui_sidebar_mode::QueryBuilding &&
ui->main.mode != ui_sidebar_mode::BuildingItems)
return NULL;
return virtual_cast<df::building_nest_boxst>(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<df::item_eggst>((*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);