Add Job::getName(job *), also available from Lua

develop
Quietust 2014-04-23 08:03:10 -05:00
parent 1d1ede279f
commit c3d45c3a1e
3 changed files with 25 additions and 0 deletions

@ -1337,6 +1337,7 @@ static const LuaWrapper::FunctionReg dfhack_job_module[] = {
WRAPM(Job,checkDesignationsNow), WRAPM(Job,checkDesignationsNow),
WRAPM(Job,isSuitableItem), WRAPM(Job,isSuitableItem),
WRAPM(Job,isSuitableMaterial), WRAPM(Job,isSuitableMaterial),
WRAPM(Job,getName),
WRAPN(is_equal, jobEqual), WRAPN(is_equal, jobEqual),
WRAPN(is_item_equal, jobItemEqual), WRAPN(is_item_equal, jobItemEqual),
{ NULL, NULL } { NULL, NULL }

@ -81,6 +81,7 @@ namespace DFHack
DFHACK_EXPORT bool isSuitableItem(df::job_item *item, df::item_type itype, int isubtype); DFHACK_EXPORT bool isSuitableItem(df::job_item *item, df::item_type itype, int isubtype);
DFHACK_EXPORT bool isSuitableMaterial(df::job_item *item, int mat_type, int mat_index); DFHACK_EXPORT bool isSuitableMaterial(df::job_item *item, int mat_type, int mat_index);
DFHACK_EXPORT std::string getName(df::job *job);
} }
DFHACK_EXPORT bool operator== (const df::job_item &a, const df::job_item &b); DFHACK_EXPORT bool operator== (const df::job_item &a, const df::job_item &b);

@ -53,6 +53,7 @@ using namespace std;
#include "df/general_ref.h" #include "df/general_ref.h"
#include "df/general_ref_unit_workerst.h" #include "df/general_ref_unit_workerst.h"
#include "df/general_ref_building_holderst.h" #include "df/general_ref_building_holderst.h"
#include "df/interface_button_building_new_jobst.h"
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
@ -476,3 +477,25 @@ bool Job::isSuitableMaterial(df::job_item *item, int mat_type, int mat_index)
return minfo.isValid() && iinfo.matches(*item, &minfo); return minfo.isValid() && iinfo.matches(*item, &minfo);
} }
std::string Job::getName(df::job *job)
{
CHECK_NULL_POINTER(job);
std::string desc;
auto button = df::allocate<df::interface_button_building_new_jobst>();
button->reaction_name = job->reaction_name;
button->hist_figure_id = job->hist_figure_id;
button->job_type = job->job_type;
button->item_type = job->item_type;
button->item_subtype = job->item_subtype;
button->mat_type = job->mat_type;
button->mat_index = job->mat_index;
button->item_category = job->item_category;
button->material_category = job->material_category;
button->getLabel(&desc);
delete button;
return desc;
}