manipulator: show social activities in job column

develop
lethosor 2017-04-28 17:26:20 -04:00
parent 71b553b305
commit 690fec9d81
1 changed files with 32 additions and 17 deletions

@ -15,8 +15,9 @@
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include <tuple> #include <tuple>
#include <VTableInterpose.h> #include <VTableInterpose.h>
#include "df/activity_event.h"
#include "df/world.h" #include "df/world.h"
#include "df/ui.h" #include "df/ui.h"
#include "df/graphic.h" #include "df/graphic.h"
@ -289,7 +290,8 @@ struct UnitInfo
int active_index; int active_index;
string squad_effective_name; string squad_effective_name;
string squad_info; string squad_info;
string job_info; string job_desc;
enum { IDLE, SOCIAL, JOB } job_mode;
bool selected; bool selected;
struct { struct {
// Used for custom professions, 1-indexed // Used for custom professions, 1-indexed
@ -363,16 +365,18 @@ bool sortBySquad (const UnitInfo *d1, const UnitInfo *d2)
bool sortByJob (const UnitInfo *d1, const UnitInfo *d2) bool sortByJob (const UnitInfo *d1, const UnitInfo *d2)
{ {
bool gt = false; if (d1->job_mode != d2->job_mode)
{
if (d1->job_info == "Idle") if (descending)
gt = false; return int(d1->job_mode) < int(d2->job_mode);
else if (d2->job_info == "Idle")
gt = true;
else else
gt = (d1->job_info > d2->job_info); return int(d1->job_mode) > int(d2->job_mode);
}
return descending ? gt : !gt; if (descending)
return d1->job_desc > d2->job_desc;
else
return d1->job_desc < d2->job_desc;
} }
bool sortByStress (const UnitInfo *d1, const UnitInfo *d2) bool sortByStress (const UnitInfo *d1, const UnitInfo *d2)
@ -1234,9 +1238,18 @@ void viewscreen_unitlaborsst::refreshNames()
cur->profession = Units::getProfessionName(unit); cur->profession = Units::getProfessionName(unit);
if (unit->job.current_job == NULL) { if (unit->job.current_job == NULL) {
cur->job_info = "Idle"; df::activity_event *event = Units::getMainSocialEvent(unit);
if (event) {
event->getName(unit->id, &cur->job_desc);
cur->job_mode = UnitInfo::SOCIAL;
}
else {
cur->job_desc = "Idle";
cur->job_mode = UnitInfo::IDLE;
}
} else { } else {
cur->job_info = DFHack::Job::getName(unit->job.current_job); cur->job_desc = DFHack::Job::getName(unit->job.current_job);
cur->job_mode = UnitInfo::JOB;
} }
if (unit->military.squad_id > -1) { if (unit->military.squad_id > -1) {
cur->squad_effective_name = Units::getSquadName(unit); cur->squad_effective_name = Units::getSquadName(unit);
@ -1283,7 +1296,7 @@ void viewscreen_unitlaborsst::calcSize()
if (detail_mode == DETAIL_MODE_SQUAD) { if (detail_mode == DETAIL_MODE_SQUAD) {
detail_cmp = units[i]->squad_info.size(); detail_cmp = units[i]->squad_info.size();
} else if (detail_mode == DETAIL_MODE_JOB) { } else if (detail_mode == DETAIL_MODE_JOB) {
detail_cmp = units[i]->job_info.size(); detail_cmp = units[i]->job_desc.size();
} else { } else {
detail_cmp = units[i]->profession.size(); detail_cmp = units[i]->profession.size();
} }
@ -1954,11 +1967,13 @@ void viewscreen_unitlaborsst::render()
fg = 11; fg = 11;
detail_str = cur->squad_info; detail_str = cur->squad_info;
} else if (detail_mode == DETAIL_MODE_JOB) { } else if (detail_mode == DETAIL_MODE_JOB) {
detail_str = cur->job_info; detail_str = cur->job_desc;
if (detail_str == "Idle") { if (cur->job_mode == UnitInfo::IDLE) {
fg = 14; fg = COLOR_YELLOW;
} else if (cur->job_mode == UnitInfo::SOCIAL) {
fg = COLOR_LIGHTGREEN;
} else { } else {
fg = 10; fg = COLOR_LIGHTCYAN;
} }
} else { } else {
fg = cur->color; fg = cur->color;