|
|
|
@ -26,6 +26,8 @@
|
|
|
|
|
#include "df/creature_graphics_role.h"
|
|
|
|
|
#include "df/creature_raw.h"
|
|
|
|
|
#include "df/caste_raw.h"
|
|
|
|
|
#include "df/historical_entity.h"
|
|
|
|
|
#include "df/entity_raw.h"
|
|
|
|
|
|
|
|
|
|
using std::set;
|
|
|
|
|
using std::vector;
|
|
|
|
@ -82,6 +84,14 @@ struct SkillColumn
|
|
|
|
|
df::job_skill skill; // displayed rating
|
|
|
|
|
char label[3]; // column header
|
|
|
|
|
bool special; // specified labor is mutually exclusive with all other special labors
|
|
|
|
|
bool isValidLabor (df::historical_entity *entity = NULL) const
|
|
|
|
|
{
|
|
|
|
|
if (labor == unit_labor::NONE)
|
|
|
|
|
return false;
|
|
|
|
|
if (entity && entity->entity_raw && !entity->entity_raw->jobs.permitted_labor[labor])
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NUM_COLUMNS (sizeof(columns) / sizeof(SkillColumn))
|
|
|
|
@ -851,7 +861,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitInfo *cur = units[input_row];
|
|
|
|
|
if (events->count(interface_key::SELECT) && (cur->allowEdit) && (columns[input_column].labor != unit_labor::NONE))
|
|
|
|
|
if (events->count(interface_key::SELECT) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
|
|
|
|
|
{
|
|
|
|
|
df::unit *unit = cur->unit;
|
|
|
|
|
const SkillColumn &col = columns[input_column];
|
|
|
|
@ -870,15 +880,17 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
|
|
|
|
|
}
|
|
|
|
|
unit->status.labors[col.labor] = newstatus;
|
|
|
|
|
}
|
|
|
|
|
if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit))
|
|
|
|
|
if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
|
|
|
|
|
{
|
|
|
|
|
df::unit *unit = cur->unit;
|
|
|
|
|
const SkillColumn &col = columns[input_column];
|
|
|
|
|
bool newstatus = (col.labor == unit_labor::NONE) ? true : !unit->status.labors[col.labor];
|
|
|
|
|
bool newstatus = !unit->status.labors[col.labor];
|
|
|
|
|
for (int i = 0; i < NUM_COLUMNS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (columns[i].group != col.group)
|
|
|
|
|
continue;
|
|
|
|
|
if (!columns[i].isValidLabor(ui->main.fortress_entity))
|
|
|
|
|
continue;
|
|
|
|
|
if (columns[i].special)
|
|
|
|
|
{
|
|
|
|
|
if (newstatus)
|
|
|
|
@ -1175,7 +1187,7 @@ void viewscreen_unitlaborsst::render()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
canToggle = (cur->allowEdit) && (columns[sel_column].labor != unit_labor::NONE);
|
|
|
|
|
canToggle = (cur->allowEdit) && columns[sel_column].isValidLabor(ui->main.fortress_entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x = 2, y = dim.y - 3;
|
|
|
|
|