Merge pull request #525 from lethosor/tweak-tradereq-pet-gender

New tweak to display pet genders on trade request screen
develop
Lethosor 2015-02-03 08:25:12 -05:00
commit 67bf26dbbe
5 changed files with 40 additions and 0 deletions

@ -6,6 +6,7 @@ DFHack Future
New Scripts New Scripts
modtools/reaction-product-trigger: triggers callbacks when products are produced (contrast with when reactions complete) modtools/reaction-product-trigger: triggers callbacks when products are produced (contrast with when reactions complete)
New Tweaks New Tweaks
tradereq-pet-gender: Displays pet genders on the trade request screen
Removed Removed
Misc Improvements Misc Improvements

@ -1337,6 +1337,7 @@ Subcommands that persist until disabled or DF quit:
:nestbox-color: Fixes the color of built nestboxes :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 :max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile
:tradereq-pet-gender: Displays pet genders on the trade request screen
fix-armory fix-armory
---------- ----------

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

@ -87,6 +87,7 @@
#include "tweaks/military-assign.h" #include "tweaks/military-assign.h"
#include "tweaks/nestbox-color.h" #include "tweaks/nestbox-color.h"
#include "tweaks/stable-cursor.h" #include "tweaks/stable-cursor.h"
#include "tweaks/tradereq-pet-gender.h"
using std::set; using std::set;
using std::vector; using std::vector;
@ -178,6 +179,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Preserve list order and cursor position when assigning to squad,\n" " Preserve list order and cursor position when assigning to squad,\n"
" i.e. stop the rightmost list of the Positions page of the military\n" " i.e. stop the rightmost list of the Positions page of the military\n"
" screen from constantly jumping to the top.\n" " screen from constantly jumping to the top.\n"
" tweak tradereq-pet-gender [disable]\n"
" Displays the gender of pets in the trade request list\n"
// " tweak military-training [disable]\n" // " tweak military-training [disable]\n"
// " Speed up melee squad training, removing inverse dependency on unit count.\n" // " Speed up melee squad training, removing inverse dependency on unit count.\n"
)); ));
@ -222,6 +225,8 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
TWEAK_HOOK("stable-cursor", stable_cursor_hook, feed); TWEAK_HOOK("stable-cursor", stable_cursor_hook, feed);
TWEAK_HOOK("tradereq-pet-gender", pet_gender_hook, render);
return CR_OK; return CR_OK;
} }

@ -0,0 +1,32 @@
#include "df/caste_raw.h"
#include "df/creature_raw.h"
#include "df/entity_sell_category.h"
#include "df/historical_entity.h"
#include "df/viewscreen_topicmeeting_takerequestsst.h"
using namespace DFHack;
using df::global::world;
using df::entity_sell_category;
struct pet_gender_hook : df::viewscreen_topicmeeting_takerequestsst {
typedef df::viewscreen_topicmeeting_takerequestsst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, render, ())
{
INTERPOSE_NEXT(render)();
if (type_categories[type_idx] == entity_sell_category::Pets)
{
df::historical_entity* entity = df::historical_entity::find(meeting->civ_id);
vector<int32_t>& races = entity->resources.animals.pet_races;
vector<int16_t>& castes = entity->resources.animals.pet_castes;
for (int i = (good_idx / 17) * 17, y = 4; i < (good_idx / 17) * 17 + 17 && i < races.size(); i++, y++) {
int x = 30 + 1 + world->raws.creatures.all[races[i]]->caste[castes[i]]->caste_name[0].size();
bool male = (bool)world->raws.creatures.all[races[i]]->caste[castes[i]]->gender;
OutputString((i == good_idx) ? COLOR_WHITE : COLOR_GREY,
x, y, male ? "\013" : "\014");
}
}
}
};
IMPLEMENT_VMETHOD_INTERPOSE(pet_gender_hook, render);