New tweak (tradereq-pet-gender): Displays pet genders on trade agreement screen

Closes #515
develop
lethosor 2015-01-28 16:54:53 -05:00
parent d153786eb4
commit 5a93de3f31
2 changed files with 37 additions and 0 deletions

@ -87,6 +87,7 @@
#include "tweaks/military-assign.h"
#include "tweaks/nestbox-color.h"
#include "tweaks/stable-cursor.h"
#include "tweaks/tradereq-pet-gender.h"
using std::set;
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"
" i.e. stop the rightmost list of the Positions page of the military\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"
// " 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("tradereq-pet-gender", pet_gender_hook, render);
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);