Merge remote-tracking branch 'lethosor/tweaks-2'

Conflicts:
	NEWS
develop
lethosor 2015-01-05 16:54:24 -05:00
commit 67f0aa774c
7 changed files with 188 additions and 1 deletions

@ -27,6 +27,9 @@ DFHack Future
hfs-pit: Digs a hole to hell under the cursor. Replaces needs_porting/hellhole.cpp
Removed
embark.lua: Obsolete, use `embark-tools`
New tweaks:
eggs-fertile: Displays an egg fertility indicator on nestboxes
max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile
Misc Improvements
embark-tools: Added basic mouse support on the local map
Made some adventure mode keybindings in dfhack.init-example only work in adventure mode

@ -2049,7 +2049,14 @@ 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>
</td>
</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">Displays a fertility indicator on nestboxes</p>
</td>
</tr>
<tr class="field"><th class="field-name" colspan="2">max-wheelbarrow:</th></tr>
<tr class="field"><td>&nbsp;</td><td class="field-body"><p class="first last">Allows assigning more than 3 wheelbarrows to a stockpile</p>
</td>
</tr>
</tbody>

@ -1332,6 +1332,8 @@ 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
:max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile
fix-armory
----------

@ -179,6 +179,7 @@ tweak import-priority-category
# Misc. UI tweaks
tweak civ-view-agreement
tweak max-wheelbarrow
###########################
# Globally acting plugins #

@ -13,6 +13,7 @@
#include "modules/Job.h"
#include "modules/Materials.h"
#include "modules/MapCache.h"
#include "modules/Buildings.h"
#include "MiscUtils.h"
@ -76,11 +77,13 @@
#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"
#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,6 +151,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Fixes overlapping text on the \"view agreement\" screen\n"
" tweak craft-age-wear [disable]\n"
" Makes cloth and leather items wear out at the correct rate (bug 6003).\n"
" tweak eggs-fertile [disable]\n"
" Displays a fertile/infertile indicator on nestboxes\n"
" tweak farm-plot-select [disable]\n"
" Adds \"Select all\" and \"Deselect all\" options to farm plot menus\n"
" tweak fast-heat <max-ticks>\n"
@ -162,6 +167,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" the priority of an entire category of imports.\n"
" tweak manager-quantity [disable]\n"
" Removes the limit of 30 jobs per manager order\n"
" tweak max-wheelbarrow [disable]\n"
" Allows assigning more than 3 wheelbarrows to a stockpile\n"
" tweak nestbox-color [disable]\n"
" Makes built nestboxes use the color of their material\n"
" tweak military-color-assigned [disable]\n"
@ -187,6 +194,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
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, render);
@ -202,6 +211,9 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("manager-quantity", manager_quantity_hook, feed);
TWEAK_HOOK("max-wheelbarrow", max_wheelbarrow_hook, render);
TWEAK_HOOK("max-wheelbarrow", max_wheelbarrow_hook, feed);
TWEAK_HOOK("military-color-assigned", military_assign_hook, render);
TWEAK_HOOK("military-stable-assign", military_assign_hook, feed);

@ -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);

@ -0,0 +1,96 @@
#include "df/building_stockpilest.h"
#include "df/viewscreen_dwarfmodest.h"
using namespace DFHack;
using namespace df::enums;
using df::global::world;
static bool in_wheelbarrow_entry;
static std::string wheelbarrow_entry;
struct max_wheelbarrow_hook : df::viewscreen_dwarfmodest {
typedef df::viewscreen_dwarfmodest interpose_base;
int wheelbarrow_count()
{
int ret = 0;
std::stringstream tmp(wheelbarrow_entry);
tmp >> ret;
return ret;
}
df::building_stockpilest* getStockpile()
{
if (ui->main.mode != ui_sidebar_mode::QueryBuilding)
return NULL;
return virtual_cast<df::building_stockpilest>(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<df::interface_key>* 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);