|
|
@ -247,12 +247,14 @@ struct UnitInfo
|
|
|
|
string transname;
|
|
|
|
string transname;
|
|
|
|
string profession;
|
|
|
|
string profession;
|
|
|
|
int8_t color;
|
|
|
|
int8_t color;
|
|
|
|
|
|
|
|
int active_index;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum altsort_mode {
|
|
|
|
enum altsort_mode {
|
|
|
|
ALTSORT_NAME,
|
|
|
|
ALTSORT_NAME,
|
|
|
|
ALTSORT_PROFESSION,
|
|
|
|
ALTSORT_PROFESSION,
|
|
|
|
ALTSORT_HAPPINESS,
|
|
|
|
ALTSORT_HAPPINESS,
|
|
|
|
|
|
|
|
ALTSORT_ARRIVAL,
|
|
|
|
ALTSORT_MAX
|
|
|
|
ALTSORT_MAX
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -284,6 +286,14 @@ bool sortByHappiness (const UnitInfo *d1, const UnitInfo *d2)
|
|
|
|
return (d1->unit->status.happiness < d2->unit->status.happiness);
|
|
|
|
return (d1->unit->status.happiness < d2->unit->status.happiness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool sortByArrival (const UnitInfo *d1, const UnitInfo *d2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (descending)
|
|
|
|
|
|
|
|
return (d1->active_index > d2->active_index);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return (d1->active_index < d2->active_index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sortBySkill (const UnitInfo *d1, const UnitInfo *d2)
|
|
|
|
bool sortBySkill (const UnitInfo *d1, const UnitInfo *d2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (sort_skill != job_skill::NONE)
|
|
|
|
if (sort_skill != job_skill::NONE)
|
|
|
@ -366,12 +376,18 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cursor_pos)
|
|
|
|
viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cursor_pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
std::map<df::unit*,int> active_idx;
|
|
|
|
|
|
|
|
auto &active = world->units.active;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < active.size(); i++)
|
|
|
|
|
|
|
|
active_idx[active[i]] = i;
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < src.size(); i++)
|
|
|
|
for (size_t i = 0; i < src.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UnitInfo *cur = new UnitInfo;
|
|
|
|
UnitInfo *cur = new UnitInfo;
|
|
|
|
df::unit *unit = src[i];
|
|
|
|
df::unit *unit = src[i];
|
|
|
|
cur->unit = unit;
|
|
|
|
cur->unit = unit;
|
|
|
|
cur->allowEdit = true;
|
|
|
|
cur->allowEdit = true;
|
|
|
|
|
|
|
|
cur->active_index = active_idx[unit];
|
|
|
|
|
|
|
|
|
|
|
|
if (unit->race != ui->race_id)
|
|
|
|
if (unit->race != ui->race_id)
|
|
|
|
cur->allowEdit = false;
|
|
|
|
cur->allowEdit = false;
|
|
|
@ -526,6 +542,15 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
|
|
|
|
if (events->count(interface_key::CURSOR_DOWN_FAST) || events->count(interface_key::CURSOR_DOWNLEFT_FAST) || events->count(interface_key::CURSOR_DOWNRIGHT_FAST))
|
|
|
|
if (events->count(interface_key::CURSOR_DOWN_FAST) || events->count(interface_key::CURSOR_DOWNLEFT_FAST) || events->count(interface_key::CURSOR_DOWNRIGHT_FAST))
|
|
|
|
sel_row += 10;
|
|
|
|
sel_row += 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((sel_row > 0) && events->count(interface_key::CURSOR_UP_Z_AUX))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sel_row = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((sel_row < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sel_row = units.size()-1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sel_row < 0)
|
|
|
|
if (sel_row < 0)
|
|
|
|
sel_row = 0;
|
|
|
|
sel_row = 0;
|
|
|
|
if (sel_row > units.size() - 1)
|
|
|
|
if (sel_row > units.size() - 1)
|
|
|
@ -759,6 +784,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
std::sort(units.begin(), units.end(), sortByHappiness);
|
|
|
|
std::sort(units.begin(), units.end(), sortByHappiness);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALTSORT_ARRIVAL:
|
|
|
|
|
|
|
|
std::sort(units.begin(), units.end(), sortByArrival);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (events->count(interface_key::CHANGETAB))
|
|
|
|
if (events->count(interface_key::CHANGETAB))
|
|
|
@ -772,6 +800,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
|
|
|
|
altsort = ALTSORT_HAPPINESS;
|
|
|
|
altsort = ALTSORT_HAPPINESS;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
|
|
|
|
altsort = ALTSORT_ARRIVAL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALTSORT_ARRIVAL:
|
|
|
|
altsort = ALTSORT_NAME;
|
|
|
|
altsort = ALTSORT_NAME;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1015,6 +1046,9 @@ void viewscreen_unitlaborsst::render()
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
case ALTSORT_HAPPINESS:
|
|
|
|
OutputString(15, x, gps->dimy - 2, "Happiness");
|
|
|
|
OutputString(15, x, gps->dimy - 2, "Happiness");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALTSORT_ARRIVAL:
|
|
|
|
|
|
|
|
OutputString(15, x, gps->dimy - 2, "Arrival");
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
OutputString(15, x, gps->dimy - 2, "Unknown");
|
|
|
|
OutputString(15, x, gps->dimy - 2, "Unknown");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|