2013-02-15 16:10:47 -07:00
|
|
|
#include "uicommon.h"
|
2015-07-28 19:48:00 -06:00
|
|
|
#include "listcolumn.h"
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
|
|
|
|
#include "df/job.h"
|
2023-01-05 18:11:01 -07:00
|
|
|
#include "df/plotinfost.h"
|
2013-02-15 16:10:47 -07:00
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/viewscreen_dwarfmodest.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/misc_trait_type.h"
|
|
|
|
#include "df/unit_misc_trait.h"
|
|
|
|
|
2015-06-13 15:13:09 -06:00
|
|
|
#include "LuaTools.h"
|
|
|
|
#include "LuaWrapper.h"
|
2013-02-15 16:10:47 -07:00
|
|
|
#include "modules/Gui.h"
|
|
|
|
#include "modules/Units.h"
|
|
|
|
#include "modules/Translation.h"
|
|
|
|
#include "modules/World.h"
|
|
|
|
#include "modules/Maps.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
#include "df/activity_entry.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
#include "df/activity_event.h"
|
|
|
|
#include "df/creature_raw.h"
|
|
|
|
#include "df/dance_form.h"
|
|
|
|
#include "df/descriptor_color.h"
|
|
|
|
#include "df/descriptor_shape.h"
|
2014-05-04 04:45:48 -06:00
|
|
|
#include "df/item_type.h"
|
|
|
|
#include "df/itemdef_ammost.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
#include "df/itemdef_armorst.h"
|
|
|
|
#include "df/itemdef_foodst.h"
|
2014-05-04 04:45:48 -06:00
|
|
|
#include "df/itemdef_glovesst.h"
|
|
|
|
#include "df/itemdef_helmst.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
#include "df/itemdef_instrumentst.h"
|
2014-05-04 04:45:48 -06:00
|
|
|
#include "df/itemdef_pantsst.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
#include "df/itemdef_shieldst.h"
|
|
|
|
#include "df/itemdef_shoesst.h"
|
|
|
|
#include "df/itemdef_siegeammost.h"
|
|
|
|
#include "df/itemdef_toolst.h"
|
|
|
|
#include "df/itemdef_toyst.h"
|
|
|
|
#include "df/itemdef_trapcompst.h"
|
|
|
|
#include "df/itemdef_weaponst.h"
|
|
|
|
#include "df/musical_form.h"
|
|
|
|
#include "df/poetic_form.h"
|
2014-05-04 04:45:48 -06:00
|
|
|
#include "df/trapcomp_flags.h"
|
2018-01-17 23:06:55 -07:00
|
|
|
#include "df/unit_preference.h"
|
|
|
|
#include "df/unit_soul.h"
|
2018-01-18 08:17:54 -07:00
|
|
|
#include "df/viewscreen_unitst.h"
|
2014-05-04 04:45:48 -06:00
|
|
|
#include "df/world_raws.h"
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
using std::deque;
|
|
|
|
|
2014-12-02 19:44:20 -07:00
|
|
|
DFHACK_PLUGIN("dwarfmonitor");
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
REQUIRE_GLOBAL(world);
|
2023-01-05 18:11:01 -07:00
|
|
|
REQUIRE_GLOBAL(plotinfo);
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
typedef int16_t activity_type;
|
|
|
|
|
2014-06-06 20:31:45 -06:00
|
|
|
#define PLUGIN_VERSION 0.9
|
2013-02-15 16:10:47 -07:00
|
|
|
#define DAY_TICKS 1200
|
|
|
|
#define DELTA_TICKS 100
|
|
|
|
|
2013-03-01 01:29:16 -07:00
|
|
|
const int min_window = 28;
|
|
|
|
const int max_history_days = 3 * min_window;
|
|
|
|
const int ticks_per_day = DAY_TICKS / DELTA_TICKS;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
|
|
|
struct less_second {
|
|
|
|
typedef pair<T1, T2> type;
|
|
|
|
bool operator ()(type const& a, type const& b) const {
|
|
|
|
return a.second > b.second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static map<df::unit *, deque<activity_type>> work_history;
|
|
|
|
|
2014-11-08 12:54:28 -07:00
|
|
|
static color_value monitor_colors[] =
|
2014-05-04 04:45:48 -06:00
|
|
|
{
|
|
|
|
COLOR_LIGHTRED,
|
|
|
|
COLOR_RED,
|
|
|
|
COLOR_YELLOW,
|
|
|
|
COLOR_WHITE,
|
|
|
|
COLOR_CYAN,
|
|
|
|
COLOR_LIGHTBLUE,
|
|
|
|
COLOR_LIGHTGREEN
|
|
|
|
};
|
|
|
|
|
|
|
|
static int get_happiness_cat(df::unit *unit)
|
|
|
|
{
|
2018-07-09 13:59:12 -06:00
|
|
|
int level = Units::getStressCategory(unit);
|
|
|
|
if (level < 0) level = 0;
|
|
|
|
if (level > 6) level = 6;
|
|
|
|
return level;
|
2014-05-04 04:45:48 -06:00
|
|
|
}
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
static int get_max_history()
|
|
|
|
{
|
2013-03-01 01:29:16 -07:00
|
|
|
return ticks_per_day * max_history_days;
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int getPercentage(const int n, const int d)
|
|
|
|
{
|
|
|
|
return static_cast<int>(
|
|
|
|
static_cast<float>(n) / static_cast<float>(d) * 100.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static string getUnitName(df::unit * unit)
|
|
|
|
{
|
|
|
|
string label = "";
|
|
|
|
auto name = Units::getVisibleName(unit);
|
|
|
|
if (name->has_name)
|
|
|
|
label = Translation::TranslateName(name, false);
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2018-01-17 23:06:55 -07:00
|
|
|
template<typename T>
|
|
|
|
static string getFormName(int32_t id, const string &default_ = "?") {
|
|
|
|
T *form = T::find(id);
|
|
|
|
if (form)
|
|
|
|
return Translation::TranslateName(&form->name);
|
|
|
|
return default_;
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
static void send_key(const df::interface_key &key)
|
|
|
|
{
|
|
|
|
set< df::interface_key > keys;
|
|
|
|
keys.insert(key);
|
|
|
|
Gui::getCurViewscreen(true)->feed(&keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void move_cursor(df::coord &pos)
|
|
|
|
{
|
|
|
|
Gui::setCursorCoords(pos.x, pos.y, pos.z);
|
2017-06-22 21:56:35 -06:00
|
|
|
Gui::refreshSidebar();
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
2018-05-12 12:59:26 -06:00
|
|
|
static void open_stats_screen();
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static int getStressCategoryColors(lua_State *L) {
|
|
|
|
const size_t n = sizeof(monitor_colors)/sizeof(color_value);
|
|
|
|
lua_createtable(L, n, 0);
|
|
|
|
for (size_t i = 0; i < n; ++i) {
|
|
|
|
Lua::Push(L, monitor_colors[i]);
|
|
|
|
lua_rawseti(L, -2, i+1);
|
2015-06-13 15:13:09 -06:00
|
|
|
}
|
2022-11-02 13:40:18 -06:00
|
|
|
return 1;
|
2015-06-13 15:13:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
DFHACK_PLUGIN_LUA_COMMANDS {
|
2022-11-02 13:40:18 -06:00
|
|
|
DFHACK_LUA_COMMAND(getStressCategoryColors),
|
2015-06-13 15:13:09 -06:00
|
|
|
DFHACK_LUA_END
|
|
|
|
};
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
#define JOB_IDLE -1
|
2013-03-02 01:58:36 -07:00
|
|
|
#define JOB_UNKNOWN -2
|
2013-02-15 16:10:47 -07:00
|
|
|
#define JOB_MILITARY -3
|
|
|
|
#define JOB_LEISURE -4
|
2013-03-02 01:58:36 -07:00
|
|
|
#define JOB_UNPRODUCTIVE -5
|
|
|
|
#define JOB_DESIGNATE -6
|
2013-02-15 16:10:47 -07:00
|
|
|
#define JOB_STORE_ITEM -7
|
2013-03-02 01:58:36 -07:00
|
|
|
#define JOB_MANUFACTURE -8
|
2013-02-15 16:10:47 -07:00
|
|
|
#define JOB_DETAILING -9
|
|
|
|
#define JOB_HUNTING -10
|
|
|
|
#define JOB_MEDICAL -14
|
2013-03-02 01:58:36 -07:00
|
|
|
#define JOB_COLLECT -15
|
|
|
|
#define JOB_CONSTRUCTION -16
|
|
|
|
#define JOB_AGRICULTURE -17
|
|
|
|
#define JOB_FOOD_PROD -18
|
|
|
|
#define JOB_MECHANICAL -19
|
|
|
|
#define JOB_ANIMALS -20
|
|
|
|
#define JOB_PRODUCTIVE -21
|
|
|
|
|
|
|
|
static map<activity_type, string> activity_labels;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
static string getActivityLabel(const activity_type activity)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
string label;
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
if (activity_labels.find(activity) != activity_labels.end())
|
|
|
|
{
|
|
|
|
label = activity_labels[activity];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-15 16:10:47 -07:00
|
|
|
string raw_label = enum_item_key_str(static_cast<df::job_type>(activity));
|
|
|
|
for (auto c = raw_label.begin(); c != raw_label.end(); c++)
|
|
|
|
{
|
|
|
|
if (label.length() > 0 && *c >= 'A' && *c <= 'Z')
|
|
|
|
label += ' ';
|
|
|
|
|
|
|
|
label += *c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
class ViewscreenDwarfStats : public dfhack_viewscreen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ViewscreenDwarfStats(df::unit *starting_selection) : selected_column(0)
|
|
|
|
{
|
|
|
|
dwarves_column.multiselect = false;
|
|
|
|
dwarves_column.auto_select = true;
|
|
|
|
dwarves_column.setTitle("Dwarves");
|
|
|
|
|
|
|
|
dwarf_activity_column.multiselect = false;
|
|
|
|
dwarf_activity_column.auto_select = true;
|
|
|
|
dwarf_activity_column.setTitle("Dwarf Activity");
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
window_days = min_window;
|
|
|
|
|
|
|
|
populateDwarfColumn(starting_selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void populateDwarfColumn(df::unit *starting_selection = NULL)
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
|
|
|
|
auto last_selected_index = dwarf_activity_column.highlighted_index;
|
2013-03-15 04:50:29 -06:00
|
|
|
dwarves_column.clear();
|
2013-03-02 01:58:36 -07:00
|
|
|
dwarf_activity_values.clear();
|
|
|
|
|
2013-03-15 04:50:29 -06:00
|
|
|
for (auto it = work_history.begin(); it != work_history.end();)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
auto unit = it->first;
|
2018-06-14 08:30:35 -06:00
|
|
|
if (!Units::isActive(unit))
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
work_history.erase(it++);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
deque<activity_type> *work_list = &it->second;
|
|
|
|
++it;
|
|
|
|
|
|
|
|
size_t dwarf_total = 0;
|
|
|
|
dwarf_activity_values[unit] = map<activity_type, size_t>();
|
2013-03-02 01:58:36 -07:00
|
|
|
size_t count = window_days * ticks_per_day;
|
|
|
|
for (auto entry = work_list->rbegin(); entry != work_list->rend() && count > 0; entry++, count--)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
if (*entry == JOB_UNKNOWN || *entry == job_type::DrinkBlood)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
++dwarf_total;
|
|
|
|
addDwarfActivity(unit, *entry);
|
|
|
|
}
|
|
|
|
|
2013-10-03 06:30:06 -06:00
|
|
|
auto &values = dwarf_activity_values[unit];
|
|
|
|
for (auto it = values.begin(); it != values.end(); ++it)
|
|
|
|
it->second = getPercentage(it->second, dwarf_total);
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
dwarves_column.add(getUnitName(unit), unit);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
dwarf_activity_column.left_margin = dwarves_column.fixWidth() + 2;
|
|
|
|
dwarves_column.filterDisplay();
|
2013-03-02 01:58:36 -07:00
|
|
|
if (starting_selection)
|
|
|
|
dwarves_column.selectItem(starting_selection);
|
|
|
|
else
|
|
|
|
dwarves_column.setHighlight(last_selected_index);
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
populateActivityColumn();
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void populateActivityColumn()
|
|
|
|
{
|
|
|
|
dwarf_activity_column.clear();
|
|
|
|
if (dwarves_column.getDisplayedListSize() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto unit = dwarves_column.getFirstSelectedElem();
|
|
|
|
if (dwarf_activity_values.find(unit) == dwarf_activity_values.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto dwarf_activities = &dwarf_activity_values[unit];
|
|
|
|
if (dwarf_activities)
|
|
|
|
{
|
|
|
|
vector<pair<activity_type, size_t>> rev_vec(dwarf_activities->begin(), dwarf_activities->end());
|
|
|
|
sort(rev_vec.begin(), rev_vec.end(), less_second<activity_type, size_t>());
|
|
|
|
|
2013-10-03 06:30:06 -06:00
|
|
|
for (auto it = rev_vec.begin(); it != rev_vec.end(); ++it)
|
|
|
|
dwarf_activity_column.add(getActivityItem(it->first, it->second), it->first);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
dwarf_activity_column.fixWidth();
|
|
|
|
dwarf_activity_column.clearSearch();
|
|
|
|
dwarf_activity_column.setHighlight(0);
|
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
void addDwarfActivity(df::unit *unit, const activity_type &activity)
|
|
|
|
{
|
|
|
|
if (dwarf_activity_values[unit].find(activity) == dwarf_activity_values[unit].end())
|
|
|
|
dwarf_activity_values[unit][activity] = 0;
|
|
|
|
|
|
|
|
dwarf_activity_values[unit][activity]++;
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
string getActivityItem(activity_type activity, size_t value)
|
|
|
|
{
|
|
|
|
return pad_string(int_to_string(value), 3) + " " + getActivityLabel(activity);
|
|
|
|
}
|
|
|
|
|
|
|
|
void feed(set<df::interface_key> *input)
|
|
|
|
{
|
|
|
|
bool key_processed = false;
|
|
|
|
switch (selected_column)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
key_processed = dwarves_column.feed(input);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
key_processed = dwarf_activity_column.feed(input);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_processed)
|
|
|
|
{
|
|
|
|
if (selected_column == 0 && dwarves_column.feed_changed_highlight)
|
|
|
|
populateActivityColumn();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input->count(interface_key::LEAVESCREEN))
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_D))
|
|
|
|
{
|
|
|
|
Screen::dismiss(this);
|
2018-05-12 12:59:26 -06:00
|
|
|
open_stats_screen();
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_Z))
|
|
|
|
{
|
|
|
|
df::unit *selected_unit = (selected_column == 0) ? dwarves_column.getFirstSelectedElem() : nullptr;
|
|
|
|
if (selected_unit)
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
Gui::resetDwarfmodeView(true);
|
|
|
|
send_key(interface_key::D_VIEWUNIT);
|
|
|
|
move_cursor(selected_unit->pos);
|
|
|
|
}
|
|
|
|
}
|
2013-03-02 01:58:36 -07:00
|
|
|
else if (input->count(interface_key::SECONDSCROLL_PAGEDOWN))
|
|
|
|
{
|
|
|
|
window_days += min_window;
|
|
|
|
if (window_days > max_history_days)
|
|
|
|
window_days = min_window;
|
|
|
|
|
|
|
|
populateDwarfColumn();
|
|
|
|
}
|
2013-02-15 16:10:47 -07:00
|
|
|
else if (input->count(interface_key::CURSOR_LEFT))
|
|
|
|
{
|
|
|
|
--selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CURSOR_RIGHT))
|
|
|
|
{
|
|
|
|
++selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (enabler->tracking_on && enabler->mouse_lbut)
|
|
|
|
{
|
|
|
|
if (dwarves_column.setHighlightByMouse())
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
populateActivityColumn();
|
|
|
|
}
|
|
|
|
else if (dwarf_activity_column.setHighlightByMouse())
|
|
|
|
selected_column = 1;
|
|
|
|
|
|
|
|
enabler->mouse_lbut = enabler->mouse_rbut = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void render()
|
|
|
|
{
|
2018-01-17 23:13:08 -07:00
|
|
|
using namespace df::enums::interface_key;
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
if (Screen::isDismissed(this))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dfhack_viewscreen::render();
|
|
|
|
|
|
|
|
Screen::clear();
|
|
|
|
Screen::drawBorder(" Dwarf Activity ");
|
|
|
|
|
|
|
|
dwarves_column.display(selected_column == 0);
|
|
|
|
dwarf_activity_column.display(selected_column == 1);
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
int32_t y = gps->dimy - 4;
|
2013-02-15 16:10:47 -07:00
|
|
|
int32_t x = 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Leave", LEAVESCREEN);
|
2013-03-02 01:58:36 -07:00
|
|
|
|
|
|
|
x += 13;
|
|
|
|
string window_label = "Window Months: " + int_to_string(window_days / min_window);
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, window_label.c_str(), SECONDSCROLL_PAGEDOWN);
|
2013-03-02 01:58:36 -07:00
|
|
|
|
|
|
|
++y;
|
|
|
|
x = 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Fort Stats", CUSTOM_SHIFT_D);
|
2013-03-02 01:58:36 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
x += 3;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Zoom Unit", CUSTOM_SHIFT_Z);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
2023-01-27 11:22:52 -07:00
|
|
|
std::vector<std::string> getFocusStrings() { return std::vector<std::string>{"dwarfmonitor_dwarfstats"}; }
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
private:
|
2013-03-02 01:58:36 -07:00
|
|
|
ListColumn<df::unit *> dwarves_column;
|
2013-02-15 16:10:47 -07:00
|
|
|
ListColumn<activity_type> dwarf_activity_column;
|
|
|
|
int selected_column;
|
2013-03-02 01:58:36 -07:00
|
|
|
size_t window_days;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
map<df::unit *, map<activity_type, size_t>> dwarf_activity_values;
|
|
|
|
|
|
|
|
void validateColumn()
|
|
|
|
{
|
|
|
|
set_to_limit(selected_column, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void resize(int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
dfhack_viewscreen::resize(x, y);
|
|
|
|
dwarves_column.resize();
|
|
|
|
dwarf_activity_column.resize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ViewscreenFortStats : public dfhack_viewscreen
|
|
|
|
{
|
|
|
|
public:
|
2013-03-01 01:29:16 -07:00
|
|
|
ViewscreenFortStats()
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
fort_activity_column.multiselect = false;
|
|
|
|
fort_activity_column.auto_select = true;
|
|
|
|
fort_activity_column.setTitle("Fort Activities");
|
2013-03-01 01:29:16 -07:00
|
|
|
fort_activity_column.bottom_margin = 4;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
dwarf_activity_column.multiselect = false;
|
|
|
|
dwarf_activity_column.auto_select = true;
|
|
|
|
dwarf_activity_column.setTitle("Units on Activity");
|
2013-03-01 01:29:16 -07:00
|
|
|
dwarf_activity_column.bottom_margin = 4;
|
2013-03-02 01:58:36 -07:00
|
|
|
dwarf_activity_column.text_clip_at = 25;
|
|
|
|
|
|
|
|
category_breakdown_column.setTitle("Category Breakdown");
|
|
|
|
category_breakdown_column.bottom_margin = 4;
|
2013-03-01 01:29:16 -07:00
|
|
|
|
|
|
|
window_days = min_window;
|
|
|
|
|
|
|
|
populateFortColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
void populateFortColumn()
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
fort_activity_count = 0;
|
|
|
|
|
|
|
|
auto last_selected_index = fort_activity_column.highlighted_index;
|
|
|
|
fort_activity_column.clear();
|
|
|
|
fort_activity_totals.clear();
|
|
|
|
dwarf_activity_values.clear();
|
2013-03-02 01:58:36 -07:00
|
|
|
category_breakdown.clear();
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
for (auto it = work_history.begin(); it != work_history.end();)
|
|
|
|
{
|
|
|
|
auto unit = it->first;
|
2018-06-14 08:30:35 -06:00
|
|
|
if (!Units::isActive(unit))
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
work_history.erase(it++);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
deque<activity_type> *work_list = &it->second;
|
|
|
|
++it;
|
|
|
|
|
2013-03-01 01:29:16 -07:00
|
|
|
size_t count = window_days * ticks_per_day;
|
|
|
|
for (auto entry = work_list->rbegin(); entry != work_list->rend() && count > 0; entry++, count--)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
if (*entry == JOB_UNKNOWN)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
++fort_activity_count;
|
|
|
|
|
|
|
|
auto real_activity = *entry;
|
|
|
|
if (real_activity < 0)
|
|
|
|
{
|
|
|
|
addFortActivity(real_activity);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto activity = static_cast<df::job_type>(real_activity);
|
|
|
|
|
|
|
|
switch (activity)
|
|
|
|
{
|
|
|
|
case job_type::Eat:
|
|
|
|
case job_type::Drink:
|
|
|
|
case job_type::Drink2:
|
|
|
|
case job_type::Sleep:
|
|
|
|
case job_type::AttendParty:
|
|
|
|
case job_type::Rest:
|
|
|
|
case job_type::CleanSelf:
|
|
|
|
case job_type::DrinkBlood:
|
|
|
|
real_activity = JOB_LEISURE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::Kidnap:
|
|
|
|
case job_type::StartingFistFight:
|
|
|
|
case job_type::SeekInfant:
|
|
|
|
case job_type::SeekArtifact:
|
|
|
|
case job_type::GoShopping:
|
|
|
|
case job_type::GoShopping2:
|
|
|
|
case job_type::RecoverPet:
|
|
|
|
case job_type::CauseTrouble:
|
|
|
|
case job_type::ReportCrime:
|
|
|
|
case job_type::BeatCriminal:
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::ExecuteCriminal:
|
|
|
|
real_activity = JOB_UNPRODUCTIVE;
|
2013-02-15 16:10:47 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::CarveUpwardStaircase:
|
|
|
|
case job_type::CarveDownwardStaircase:
|
|
|
|
case job_type::CarveUpDownStaircase:
|
|
|
|
case job_type::CarveRamp:
|
|
|
|
case job_type::DigChannel:
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::Dig:
|
|
|
|
case job_type::CarveTrack:
|
|
|
|
case job_type::CarveFortification:
|
|
|
|
real_activity = JOB_DESIGNATE;
|
2013-02-15 16:10:47 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::StoreOwnedItem:
|
|
|
|
case job_type::PlaceItemInTomb:
|
|
|
|
case job_type::StoreItemInStockpile:
|
|
|
|
case job_type::StoreItemInBag:
|
|
|
|
case job_type::StoreItemInHospital:
|
|
|
|
case job_type::StoreWeapon:
|
|
|
|
case job_type::StoreArmor:
|
|
|
|
case job_type::StoreItemInBarrel:
|
|
|
|
case job_type::StoreItemInBin:
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::BringItemToDepot:
|
|
|
|
case job_type::BringItemToShop:
|
|
|
|
case job_type::GetProvisions:
|
|
|
|
case job_type::FillWaterskin:
|
|
|
|
case job_type::FillWaterskin2:
|
|
|
|
case job_type::CheckChest:
|
|
|
|
case job_type::PickupEquipment:
|
|
|
|
case job_type::DumpItem:
|
|
|
|
case job_type::PushTrackVehicle:
|
|
|
|
case job_type::PlaceTrackVehicle:
|
|
|
|
case job_type::StoreItemInVehicle:
|
2013-02-15 16:10:47 -07:00
|
|
|
real_activity = JOB_STORE_ITEM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::ConstructDoor:
|
|
|
|
case job_type::ConstructFloodgate:
|
|
|
|
case job_type::ConstructBed:
|
|
|
|
case job_type::ConstructThrone:
|
|
|
|
case job_type::ConstructCoffin:
|
|
|
|
case job_type::ConstructTable:
|
|
|
|
case job_type::ConstructChest:
|
|
|
|
case job_type::ConstructBin:
|
|
|
|
case job_type::ConstructArmorStand:
|
|
|
|
case job_type::ConstructWeaponRack:
|
|
|
|
case job_type::ConstructCabinet:
|
|
|
|
case job_type::ConstructStatue:
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::ConstructBlocks:
|
|
|
|
case job_type::MakeRawGlass:
|
|
|
|
case job_type::MakeCrafts:
|
|
|
|
case job_type::MintCoins:
|
|
|
|
case job_type::CutGems:
|
|
|
|
case job_type::CutGlass:
|
|
|
|
case job_type::EncrustWithGems:
|
|
|
|
case job_type::EncrustWithGlass:
|
|
|
|
case job_type::SmeltOre:
|
|
|
|
case job_type::MeltMetalObject:
|
|
|
|
case job_type::ExtractMetalStrands:
|
|
|
|
case job_type::MakeWeapon:
|
|
|
|
case job_type::ForgeAnvil:
|
|
|
|
case job_type::ConstructCatapultParts:
|
|
|
|
case job_type::ConstructBallistaParts:
|
|
|
|
case job_type::MakeArmor:
|
|
|
|
case job_type::MakeHelm:
|
|
|
|
case job_type::MakePants:
|
|
|
|
case job_type::StudWith:
|
|
|
|
case job_type::ProcessPlantsVial:
|
|
|
|
case job_type::ProcessPlantsBarrel:
|
|
|
|
case job_type::WeaveCloth:
|
|
|
|
case job_type::MakeGloves:
|
|
|
|
case job_type::MakeShoes:
|
|
|
|
case job_type::MakeShield:
|
|
|
|
case job_type::MakeCage:
|
|
|
|
case job_type::MakeChain:
|
|
|
|
case job_type::MakeFlask:
|
|
|
|
case job_type::MakeGoblet:
|
|
|
|
case job_type::MakeToy:
|
|
|
|
case job_type::MakeAnimalTrap:
|
|
|
|
case job_type::MakeBarrel:
|
|
|
|
case job_type::MakeBucket:
|
|
|
|
case job_type::MakeWindow:
|
|
|
|
case job_type::MakeTotem:
|
|
|
|
case job_type::MakeAmmo:
|
|
|
|
case job_type::DecorateWith:
|
|
|
|
case job_type::MakeBackpack:
|
|
|
|
case job_type::MakeQuiver:
|
|
|
|
case job_type::MakeBallistaArrowHead:
|
|
|
|
case job_type::AssembleSiegeAmmo:
|
|
|
|
case job_type::ConstructMechanisms:
|
|
|
|
case job_type::MakeTrapComponent:
|
|
|
|
case job_type::ExtractFromPlants:
|
|
|
|
case job_type::ExtractFromRawFish:
|
|
|
|
case job_type::ExtractFromLandAnimal:
|
|
|
|
case job_type::MakeCharcoal:
|
|
|
|
case job_type::MakeAsh:
|
|
|
|
case job_type::MakeLye:
|
|
|
|
case job_type::MakePotashFromLye:
|
|
|
|
case job_type::MakePotashFromAsh:
|
|
|
|
case job_type::DyeThread:
|
|
|
|
case job_type::DyeCloth:
|
|
|
|
case job_type::SewImage:
|
|
|
|
case job_type::MakePipeSection:
|
|
|
|
case job_type::ConstructHatchCover:
|
|
|
|
case job_type::ConstructGrate:
|
|
|
|
case job_type::ConstructQuern:
|
|
|
|
case job_type::ConstructMillstone:
|
|
|
|
case job_type::ConstructSplint:
|
|
|
|
case job_type::ConstructCrutch:
|
|
|
|
case job_type::ConstructTractionBench:
|
|
|
|
case job_type::CustomReaction:
|
|
|
|
case job_type::ConstructSlab:
|
|
|
|
case job_type::EngraveSlab:
|
|
|
|
case job_type::SpinThread:
|
|
|
|
case job_type::MakeTool:
|
|
|
|
real_activity = JOB_MANUFACTURE;
|
2013-02-15 16:10:47 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::DetailFloor:
|
|
|
|
case job_type::DetailWall:
|
|
|
|
real_activity = JOB_DETAILING;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::Hunt:
|
|
|
|
case job_type::ReturnKill:
|
|
|
|
case job_type::HuntVermin:
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::GatherPlants:
|
|
|
|
case job_type::Fish:
|
|
|
|
case job_type::CatchLiveFish:
|
|
|
|
case job_type::BaitTrap:
|
|
|
|
case job_type::InstallColonyInHive:
|
2013-02-15 16:10:47 -07:00
|
|
|
real_activity = JOB_HUNTING;
|
|
|
|
break;
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::RemoveConstruction:
|
|
|
|
case job_type::DestroyBuilding:
|
|
|
|
case job_type::RemoveStairs:
|
|
|
|
case job_type::ConstructBuilding:
|
|
|
|
real_activity = JOB_CONSTRUCTION;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::FellTree:
|
|
|
|
case job_type::CollectWebs:
|
|
|
|
case job_type::CollectSand:
|
|
|
|
case job_type::DrainAquarium:
|
|
|
|
case job_type::FillAquarium:
|
|
|
|
case job_type::FillPond:
|
|
|
|
case job_type::CollectClay:
|
|
|
|
real_activity = JOB_COLLECT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::TrainHuntingAnimal:
|
|
|
|
case job_type::TrainWarAnimal:
|
|
|
|
case job_type::CatchLiveLandAnimal:
|
|
|
|
case job_type::TameVermin:
|
|
|
|
case job_type::TameAnimal:
|
|
|
|
case job_type::ChainAnimal:
|
|
|
|
case job_type::UnchainAnimal:
|
|
|
|
case job_type::UnchainPet:
|
|
|
|
case job_type::ReleaseLargeCreature:
|
|
|
|
case job_type::ReleasePet:
|
|
|
|
case job_type::ReleaseSmallCreature:
|
|
|
|
case job_type::HandleSmallCreature:
|
|
|
|
case job_type::HandleLargeCreature:
|
|
|
|
case job_type::CageLargeCreature:
|
|
|
|
case job_type::CageSmallCreature:
|
|
|
|
case job_type::PitLargeAnimal:
|
|
|
|
case job_type::PitSmallAnimal:
|
|
|
|
case job_type::SlaughterAnimal:
|
|
|
|
case job_type::ShearCreature:
|
|
|
|
case job_type::PenLargeAnimal:
|
|
|
|
case job_type::PenSmallAnimal:
|
|
|
|
case job_type::TrainAnimal:
|
|
|
|
real_activity = JOB_ANIMALS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::PlantSeeds:
|
|
|
|
case job_type::HarvestPlants:
|
|
|
|
case job_type::FertilizeField:
|
|
|
|
real_activity = JOB_AGRICULTURE;
|
|
|
|
break;
|
2014-11-08 12:54:28 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
case job_type::ButcherAnimal:
|
|
|
|
case job_type::PrepareRawFish:
|
|
|
|
case job_type::MillPlants:
|
|
|
|
case job_type::MilkCreature:
|
|
|
|
case job_type::MakeCheese:
|
|
|
|
case job_type::PrepareMeal:
|
|
|
|
case job_type::ProcessPlants:
|
|
|
|
case job_type::CollectHiveProducts:
|
|
|
|
real_activity = JOB_FOOD_PROD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::LoadCatapult:
|
|
|
|
case job_type::LoadBallista:
|
|
|
|
case job_type::FireCatapult:
|
|
|
|
case job_type::FireBallista:
|
|
|
|
real_activity = JOB_MILITARY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::LoadCageTrap:
|
|
|
|
case job_type::LoadStoneTrap:
|
|
|
|
case job_type::LoadWeaponTrap:
|
|
|
|
case job_type::CleanTrap:
|
|
|
|
case job_type::LinkBuildingToTrigger:
|
|
|
|
case job_type::PullLever:
|
|
|
|
real_activity = JOB_MECHANICAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::RecoverWounded:
|
|
|
|
case job_type::DiagnosePatient:
|
|
|
|
case job_type::ImmobilizeBreak:
|
|
|
|
case job_type::DressWound:
|
|
|
|
case job_type::CleanPatient:
|
|
|
|
case job_type::Surgery:
|
|
|
|
case job_type::Suture:
|
|
|
|
case job_type::SetBone:
|
|
|
|
case job_type::PlaceInTraction:
|
|
|
|
case job_type::GiveWater:
|
|
|
|
case job_type::GiveFood:
|
|
|
|
case job_type::GiveWater2:
|
|
|
|
case job_type::GiveFood2:
|
|
|
|
case job_type::BringCrutch:
|
|
|
|
case job_type::ApplyCast:
|
|
|
|
real_activity = JOB_MEDICAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case job_type::OperatePump:
|
|
|
|
case job_type::ManageWorkOrders:
|
|
|
|
case job_type::UpdateStockpileRecords:
|
|
|
|
case job_type::TradeAtDepot:
|
|
|
|
real_activity = JOB_PRODUCTIVE;
|
|
|
|
break;
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
addFortActivity(real_activity);
|
2013-03-02 01:58:36 -07:00
|
|
|
addCategoryActivity(real_activity, *entry);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dwarf_activity_values.find(real_activity) == dwarf_activity_values.end())
|
|
|
|
dwarf_activity_values[real_activity] = map<df::unit *, size_t>();
|
|
|
|
|
|
|
|
map<df::unit *, size_t> &activity_for_dwarf = dwarf_activity_values[real_activity];
|
|
|
|
if (activity_for_dwarf.find(unit) == activity_for_dwarf.end())
|
|
|
|
activity_for_dwarf[unit] = 0;
|
|
|
|
|
|
|
|
++activity_for_dwarf[unit];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<pair<activity_type, size_t>> rev_vec(fort_activity_totals.begin(), fort_activity_totals.end());
|
|
|
|
sort(rev_vec.begin(), rev_vec.end(), less_second<activity_type, size_t>());
|
2013-03-01 01:29:16 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
for (auto rev_it = rev_vec.begin(); rev_it != rev_vec.end(); rev_it++)
|
|
|
|
{
|
|
|
|
auto activity = rev_it->first;
|
|
|
|
addToFortAverageColumn(activity);
|
|
|
|
|
|
|
|
for (auto it = dwarf_activity_values[activity].begin(); it != dwarf_activity_values[activity].end(); it++)
|
|
|
|
{
|
|
|
|
auto avg = getPercentage(it->second, getFortActivityCount(activity));
|
|
|
|
dwarf_activity_values[activity][it->first] = avg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
for (auto cat_it = category_breakdown.begin(); cat_it != category_breakdown.end(); cat_it++)
|
|
|
|
{
|
|
|
|
auto cat_total = fort_activity_totals[cat_it->first];
|
|
|
|
for (auto val_it = cat_it->second.begin(); val_it != cat_it->second.end(); val_it++)
|
|
|
|
{
|
|
|
|
category_breakdown[cat_it->first][val_it->first] = getPercentage(val_it->second, cat_total);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
dwarf_activity_column.left_margin = fort_activity_column.fixWidth() + 2;
|
|
|
|
fort_activity_column.filterDisplay();
|
2013-03-01 01:29:16 -07:00
|
|
|
fort_activity_column.setHighlight(last_selected_index);
|
2013-02-15 16:10:47 -07:00
|
|
|
populateDwarfColumn();
|
2013-03-02 01:58:36 -07:00
|
|
|
populateCategoryBreakdownColumn();
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
2013-03-01 01:29:16 -07:00
|
|
|
void populateDwarfColumn()
|
|
|
|
{
|
|
|
|
dwarf_activity_column.clear();
|
2013-03-02 01:58:36 -07:00
|
|
|
if (fort_activity_column.getDisplayListSize() > 0)
|
|
|
|
{
|
|
|
|
activity_type selected_activity = fort_activity_column.getFirstSelectedElem();
|
|
|
|
auto dwarf_activities = &dwarf_activity_values[selected_activity];
|
|
|
|
if (dwarf_activities)
|
|
|
|
{
|
|
|
|
vector<pair<df::unit *, size_t>> rev_vec(dwarf_activities->begin(), dwarf_activities->end());
|
|
|
|
sort(rev_vec.begin(), rev_vec.end(), less_second<df::unit *, size_t>());
|
|
|
|
|
2013-10-03 06:30:06 -06:00
|
|
|
for (auto it = rev_vec.begin(); it != rev_vec.end(); ++it)
|
|
|
|
dwarf_activity_column.add(getDwarfAverage(it->first, it->second), it->first);
|
2013-03-02 01:58:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
category_breakdown_column.left_margin = dwarf_activity_column.fixWidth() + 2;
|
|
|
|
dwarf_activity_column.clearSearch();
|
|
|
|
dwarf_activity_column.setHighlight(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void populateCategoryBreakdownColumn()
|
|
|
|
{
|
|
|
|
category_breakdown_column.clear();
|
2013-03-01 01:29:16 -07:00
|
|
|
if (fort_activity_column.getDisplayListSize() == 0)
|
|
|
|
return;
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
auto selected_activity = fort_activity_column.getFirstSelectedElem();
|
|
|
|
auto category_activities = &category_breakdown[selected_activity];
|
|
|
|
if (category_activities)
|
2013-03-01 01:29:16 -07:00
|
|
|
{
|
2013-03-02 01:58:36 -07:00
|
|
|
vector<pair<activity_type, size_t>> rev_vec(category_activities->begin(), category_activities->end());
|
|
|
|
sort(rev_vec.begin(), rev_vec.end(), less_second<activity_type, size_t>());
|
2013-03-01 01:29:16 -07:00
|
|
|
|
2013-10-03 06:30:06 -06:00
|
|
|
for (auto it = rev_vec.begin(); it != rev_vec.end(); ++it)
|
|
|
|
category_breakdown_column.add(getBreakdownAverage(it->first, it->second), it->first);
|
2013-03-01 01:29:16 -07:00
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
category_breakdown_column.fixWidth();
|
|
|
|
category_breakdown_column.clearSearch();
|
|
|
|
category_breakdown_column.setHighlight(0);
|
2013-03-01 01:29:16 -07:00
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
void addToFortAverageColumn(activity_type &type)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
if (getFortActivityCount(type))
|
2013-03-02 01:58:36 -07:00
|
|
|
fort_activity_column.add(getFortAverage(type), type);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
string getFortAverage(const activity_type &activity)
|
|
|
|
{
|
|
|
|
auto average = getPercentage(getFortActivityCount(activity), fort_activity_count);
|
|
|
|
auto label = getActivityLabel(activity);
|
|
|
|
auto result = pad_string(int_to_string(average), 3) + " " + label;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
string getDwarfAverage(df::unit *unit, const size_t value)
|
|
|
|
{
|
|
|
|
auto label = getUnitName(unit);
|
|
|
|
auto result = pad_string(int_to_string(value), 3) + " " + label;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
string getBreakdownAverage(activity_type activity, const size_t value)
|
|
|
|
{
|
|
|
|
auto label = getActivityLabel(activity);
|
|
|
|
auto result = pad_string(int_to_string(value), 3) + " " + label;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getFortActivityCount(const activity_type activity)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
if (fort_activity_totals.find(activity) == fort_activity_totals.end())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return fort_activity_totals[activity];
|
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
void addFortActivity(const activity_type activity)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
|
|
|
if (fort_activity_totals.find(activity) == fort_activity_totals.end())
|
|
|
|
fort_activity_totals[activity] = 0;
|
|
|
|
|
|
|
|
fort_activity_totals[activity]++;
|
|
|
|
}
|
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
void addCategoryActivity(const int category, const activity_type activity)
|
|
|
|
{
|
|
|
|
if (category_breakdown.find(category) == category_breakdown.end())
|
|
|
|
category_breakdown[category] = map<activity_type, size_t>();
|
|
|
|
|
|
|
|
if (category_breakdown[category].find(activity) == category_breakdown[category].end())
|
|
|
|
category_breakdown[category][activity] = 0;
|
|
|
|
|
|
|
|
category_breakdown[category][activity]++;
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
void feed(set<df::interface_key> *input)
|
|
|
|
{
|
|
|
|
bool key_processed = false;
|
|
|
|
switch (selected_column)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
key_processed = fort_activity_column.feed(input);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
key_processed = dwarf_activity_column.feed(input);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_processed)
|
|
|
|
{
|
|
|
|
if (selected_column == 0 && fort_activity_column.feed_changed_highlight)
|
2013-03-02 01:58:36 -07:00
|
|
|
{
|
2013-02-15 16:10:47 -07:00
|
|
|
populateDwarfColumn();
|
2013-03-02 01:58:36 -07:00
|
|
|
populateCategoryBreakdownColumn();
|
|
|
|
}
|
2014-11-08 12:54:28 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input->count(interface_key::LEAVESCREEN))
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
return;
|
|
|
|
}
|
2013-03-01 01:29:16 -07:00
|
|
|
else if (input->count(interface_key::SECONDSCROLL_PAGEDOWN))
|
|
|
|
{
|
|
|
|
window_days += min_window;
|
|
|
|
if (window_days > max_history_days)
|
|
|
|
window_days = min_window;
|
|
|
|
|
|
|
|
populateFortColumn();
|
|
|
|
}
|
2013-02-15 16:10:47 -07:00
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_D))
|
|
|
|
{
|
|
|
|
df::unit *selected_unit = (selected_column == 1) ? dwarf_activity_column.getFirstSelectedElem() : nullptr;
|
|
|
|
Screen::dismiss(this);
|
2018-06-14 08:12:06 -06:00
|
|
|
Screen::show(dts::make_unique<ViewscreenDwarfStats>(selected_unit), plugin_self);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_Z))
|
|
|
|
{
|
|
|
|
df::unit *selected_unit = (selected_column == 1) ? dwarf_activity_column.getFirstSelectedElem() : nullptr;
|
|
|
|
if (selected_unit)
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
Gui::resetDwarfmodeView(true);
|
|
|
|
send_key(interface_key::D_VIEWUNIT);
|
|
|
|
move_cursor(selected_unit->pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CURSOR_LEFT))
|
|
|
|
{
|
|
|
|
--selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CURSOR_RIGHT))
|
|
|
|
{
|
|
|
|
++selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (enabler->tracking_on && enabler->mouse_lbut)
|
|
|
|
{
|
|
|
|
if (fort_activity_column.setHighlightByMouse())
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
populateDwarfColumn();
|
|
|
|
}
|
|
|
|
else if (dwarf_activity_column.setHighlightByMouse())
|
|
|
|
selected_column = 1;
|
|
|
|
|
|
|
|
enabler->mouse_lbut = enabler->mouse_rbut = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void render()
|
|
|
|
{
|
2018-01-17 23:13:08 -07:00
|
|
|
using namespace df::enums::interface_key;
|
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
if (Screen::isDismissed(this))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dfhack_viewscreen::render();
|
|
|
|
|
|
|
|
Screen::clear();
|
|
|
|
Screen::drawBorder(" Fortress Efficiency ");
|
|
|
|
|
|
|
|
fort_activity_column.display(selected_column == 0);
|
|
|
|
dwarf_activity_column.display(selected_column == 1);
|
2013-03-02 01:58:36 -07:00
|
|
|
category_breakdown_column.display(false);
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2013-03-01 01:29:16 -07:00
|
|
|
int32_t y = gps->dimy - 4;
|
2013-02-15 16:10:47 -07:00
|
|
|
int32_t x = 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Leave", LEAVESCREEN);
|
2013-03-01 01:29:16 -07:00
|
|
|
|
|
|
|
x += 13;
|
|
|
|
string window_label = "Window Months: " + int_to_string(window_days / min_window);
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, window_label.c_str(), SECONDSCROLL_PAGEDOWN);
|
2013-03-01 01:29:16 -07:00
|
|
|
|
|
|
|
++y;
|
|
|
|
x = 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Dwarf Stats", CUSTOM_SHIFT_D);
|
2013-03-01 01:29:16 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
x += 3;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Zoom Unit", CUSTOM_SHIFT_Z);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
2023-01-27 11:22:52 -07:00
|
|
|
std::vector<std::string> getFocusStrings() { return std::vector<std::string>{"dwarfmonitor_fortstats"}; }
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
private:
|
2013-03-02 01:58:36 -07:00
|
|
|
ListColumn<activity_type> fort_activity_column, category_breakdown_column;
|
|
|
|
ListColumn<df::unit *> dwarf_activity_column;
|
2013-02-15 16:10:47 -07:00
|
|
|
int selected_column;
|
|
|
|
|
|
|
|
map<activity_type, size_t> fort_activity_totals;
|
2013-03-02 01:58:36 -07:00
|
|
|
map<int, map<activity_type, size_t>> category_breakdown;
|
2013-02-15 16:10:47 -07:00
|
|
|
map<activity_type, map<df::unit *, size_t>> dwarf_activity_values;
|
|
|
|
size_t fort_activity_count;
|
2013-03-01 01:29:16 -07:00
|
|
|
size_t window_days;
|
2014-11-08 12:54:28 -07:00
|
|
|
|
2013-03-02 01:58:36 -07:00
|
|
|
vector<activity_type> listed_activities;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
void validateColumn()
|
|
|
|
{
|
|
|
|
set_to_limit(selected_column, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void resize(int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
dfhack_viewscreen::resize(x, y);
|
|
|
|
fort_activity_column.resize();
|
|
|
|
dwarf_activity_column.resize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
|
|
|
|
struct preference_map
|
|
|
|
{
|
|
|
|
df::unit_preference pref;
|
|
|
|
vector<df::unit *> dwarves;
|
|
|
|
string label;
|
|
|
|
|
|
|
|
string getItemLabel()
|
|
|
|
{
|
|
|
|
label = ENUM_ATTR_STR(item_type, caption, pref.item_type);
|
|
|
|
switch (pref.item_type)
|
|
|
|
{
|
|
|
|
case (df::item_type::WEAPON):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.weapons, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::TRAPCOMP):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.trapcomps, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::TOY):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.toys, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::TOOL):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.tools, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::INSTRUMENT):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.instruments, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::ARMOR):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.armor, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::AMMO):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.ammo, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::SIEGEAMMO):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.siege_ammo, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::GLOVES):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.gloves, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::SHOES):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.shoes, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::SHIELD):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.shields, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::HELM):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.helms, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::PANTS):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.pants, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
case (df::item_type::FOOD):
|
2020-10-11 18:45:56 -06:00
|
|
|
{
|
|
|
|
auto *def = vector_get(world->raws.itemdefs.food, pref.item_subtype);
|
|
|
|
if (def)
|
|
|
|
label = def->name;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2020-10-11 18:45:56 -06:00
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
|
|
|
|
default:
|
2018-01-18 08:17:40 -07:00
|
|
|
label = ENUM_ATTR_STR(item_type, caption, pref.item_type);
|
|
|
|
if (label.size())
|
|
|
|
{
|
|
|
|
if (label[label.size() - 1] == 's')
|
|
|
|
label += "es";
|
|
|
|
else
|
|
|
|
label += "s";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = "UNKNOWN";
|
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
void makeLabel()
|
|
|
|
{
|
|
|
|
label = "";
|
|
|
|
|
|
|
|
typedef df::unit_preference::T_type T_type;
|
|
|
|
df::world_raws &raws = world->raws;
|
|
|
|
switch (pref.type)
|
|
|
|
{
|
|
|
|
case (T_type::LikeCreature):
|
|
|
|
{
|
2018-01-18 07:54:33 -07:00
|
|
|
label = "Creature :" + Units::getRaceNamePluralById(pref.creature_id);
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::HateCreature):
|
|
|
|
{
|
2018-01-18 07:54:33 -07:00
|
|
|
label = "Hates :" + Units::getRaceNamePluralById(pref.creature_id);
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::LikeItem):
|
|
|
|
label = "Item :" + getItemLabel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeFood):
|
|
|
|
{
|
|
|
|
label = "Food :";
|
|
|
|
if (pref.matindex < 0 || pref.item_type == item_type::MEAT)
|
|
|
|
{
|
|
|
|
auto index = (pref.item_type == item_type::FISH) ? pref.mattype : pref.matindex;
|
|
|
|
if (index > 0)
|
|
|
|
{
|
|
|
|
auto creature = df::creature_raw::find(index);
|
|
|
|
if (creature)
|
|
|
|
label += creature->name[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label += "Invalid";
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::LikeMaterial):
|
|
|
|
{
|
|
|
|
if (label.length() == 0)
|
|
|
|
label += "Material :";
|
|
|
|
MaterialInfo matinfo(pref.mattype, pref.matindex);
|
|
|
|
if (pref.type == T_type::LikeFood && pref.item_type == item_type::PLANT)
|
|
|
|
{
|
|
|
|
label += matinfo.material->prefix;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
label += matinfo.toString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::LikePlant):
|
|
|
|
{
|
|
|
|
df::plant_raw *p = raws.plants.all[pref.plant_id];
|
|
|
|
label += "Plant :" + p->name_plural;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::LikeShape):
|
2018-03-10 14:53:45 -07:00
|
|
|
label += "Shape :" + raws.descriptors.shapes[pref.shape_id]->name_plural;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeTree):
|
|
|
|
{
|
|
|
|
df::plant_raw *p = raws.plants.all[pref.plant_id];
|
|
|
|
label += "Tree :" + p->name_plural;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (T_type::LikeColor):
|
2018-03-10 14:53:45 -07:00
|
|
|
label += "Color :" + raws.descriptors.colors[pref.color_id]->name;
|
2014-05-04 04:45:48 -06:00
|
|
|
break;
|
2018-01-17 23:06:55 -07:00
|
|
|
|
|
|
|
case (T_type::LikePoeticForm):
|
|
|
|
label += "Poetry :" + getFormName<df::poetic_form>(pref.poetic_form_id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeMusicalForm):
|
|
|
|
label += "Music :" + getFormName<df::musical_form>(pref.musical_form_id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeDanceForm):
|
|
|
|
label += "Dance :" + getFormName<df::dance_form>(pref.dance_form_id);
|
|
|
|
break;
|
|
|
|
|
2018-01-17 23:07:20 -07:00
|
|
|
default:
|
|
|
|
label += string("UNKNOWN ") + ENUM_KEY_STR(unit_preference::T_type, pref.type);
|
|
|
|
break;
|
2014-05-04 04:45:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ViewscreenPreferences : public dfhack_viewscreen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ViewscreenPreferences()
|
|
|
|
{
|
|
|
|
preferences_column.multiselect = false;
|
|
|
|
preferences_column.auto_select = true;
|
|
|
|
preferences_column.setTitle("Preference");
|
|
|
|
preferences_column.bottom_margin = 3;
|
2018-01-18 08:17:54 -07:00
|
|
|
preferences_column.search_margin = 50;
|
2014-05-04 04:45:48 -06:00
|
|
|
|
|
|
|
dwarf_column.multiselect = false;
|
|
|
|
dwarf_column.auto_select = true;
|
|
|
|
dwarf_column.allow_null = true;
|
|
|
|
dwarf_column.setTitle("Units with Preference");
|
|
|
|
dwarf_column.bottom_margin = 3;
|
2018-01-18 08:17:54 -07:00
|
|
|
dwarf_column.search_margin = 50;
|
2014-05-04 04:45:48 -06:00
|
|
|
|
|
|
|
populatePreferencesColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
void populatePreferencesColumn()
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
|
|
|
|
auto last_selected_index = preferences_column.highlighted_index;
|
|
|
|
preferences_column.clear();
|
|
|
|
preference_totals.clear();
|
|
|
|
|
|
|
|
for (auto iter = world->units.active.begin(); iter != world->units.active.end(); iter++)
|
|
|
|
{
|
|
|
|
df::unit* unit = *iter;
|
|
|
|
if (!Units::isCitizen(unit))
|
|
|
|
continue;
|
|
|
|
|
2018-06-14 08:30:35 -06:00
|
|
|
if (!DFHack::Units::isActive(unit))
|
2014-05-04 04:45:48 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!unit->status.current_soul)
|
|
|
|
continue;
|
|
|
|
|
2014-11-08 12:54:28 -07:00
|
|
|
for (auto it = unit->status.current_soul->preferences.begin();
|
2014-05-04 04:45:48 -06:00
|
|
|
it != unit->status.current_soul->preferences.end();
|
|
|
|
it++)
|
|
|
|
{
|
|
|
|
auto pref = *it;
|
|
|
|
if (!pref->active)
|
|
|
|
continue;
|
|
|
|
bool foundInStore = false;
|
|
|
|
for (size_t pref_index = 0; pref_index < preferences_store.size(); pref_index++)
|
|
|
|
{
|
|
|
|
if (isMatchingPreference(preferences_store[pref_index].pref, *pref))
|
|
|
|
{
|
|
|
|
foundInStore = true;
|
|
|
|
preferences_store[pref_index].dwarves.push_back(unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundInStore)
|
|
|
|
{
|
|
|
|
size_t pref_index = preferences_store.size();
|
|
|
|
preferences_store.resize(pref_index + 1);
|
|
|
|
preferences_store[pref_index].pref = *pref;
|
|
|
|
preferences_store[pref_index].dwarves.push_back(unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < preferences_store.size(); i++)
|
|
|
|
{
|
|
|
|
preference_totals[i] = preferences_store[i].dwarves.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<pair<size_t, size_t>> rev_vec(preference_totals.begin(), preference_totals.end());
|
|
|
|
sort(rev_vec.begin(), rev_vec.end(), less_second<size_t, size_t>());
|
|
|
|
|
|
|
|
for (auto rev_it = rev_vec.begin(); rev_it != rev_vec.end(); rev_it++)
|
|
|
|
{
|
|
|
|
auto pref_index = rev_it->first;
|
|
|
|
preferences_store[pref_index].makeLabel();
|
|
|
|
|
|
|
|
string label = pad_string(int_to_string(rev_it->second), 3);
|
|
|
|
label += " ";
|
|
|
|
label += preferences_store[pref_index].label;
|
|
|
|
ListEntry<size_t> elem(label, pref_index, "", getItemColor(preferences_store[pref_index].pref.type));
|
|
|
|
preferences_column.add(elem);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwarf_column.left_margin = preferences_column.fixWidth() + 2;
|
|
|
|
preferences_column.filterDisplay();
|
|
|
|
preferences_column.setHighlight(last_selected_index);
|
|
|
|
populateDwarfColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMatchingPreference(df::unit_preference &lhs, df::unit_preference &rhs)
|
|
|
|
{
|
|
|
|
if (lhs.type != rhs.type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
typedef df::unit_preference::T_type T_type;
|
|
|
|
switch (lhs.type)
|
|
|
|
{
|
|
|
|
case (T_type::LikeCreature):
|
|
|
|
if (lhs.creature_id != rhs.creature_id)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::HateCreature):
|
|
|
|
if (lhs.creature_id != rhs.creature_id)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeFood):
|
|
|
|
if (lhs.item_type != rhs.item_type)
|
|
|
|
return false;
|
|
|
|
if (lhs.mattype != rhs.mattype || lhs.matindex != rhs.matindex)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeItem):
|
|
|
|
if (lhs.item_type != rhs.item_type || lhs.item_subtype != rhs.item_subtype)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeMaterial):
|
|
|
|
if (lhs.mattype != rhs.mattype || lhs.matindex != rhs.matindex)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikePlant):
|
|
|
|
if (lhs.plant_id != rhs.plant_id)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeShape):
|
|
|
|
if (lhs.shape_id != rhs.shape_id)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeTree):
|
|
|
|
if (lhs.item_type != rhs.item_type)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeColor):
|
|
|
|
if (lhs.color_id != rhs.color_id)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
|
2018-01-17 23:06:55 -07:00
|
|
|
case (T_type::LikePoeticForm):
|
|
|
|
return lhs.poetic_form_id == rhs.poetic_form_id;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeMusicalForm):
|
|
|
|
return lhs.musical_form_id == rhs.musical_form_id;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (T_type::LikeDanceForm):
|
|
|
|
return lhs.dance_form_id == rhs.dance_form_id;
|
|
|
|
break;
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
UIColor getItemColor(const df::unit_preference::T_type &type) const
|
|
|
|
{
|
|
|
|
typedef df::unit_preference::T_type T_type;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (T_type::LikeCreature):
|
|
|
|
return COLOR_WHITE;
|
|
|
|
|
|
|
|
case (T_type::HateCreature):
|
|
|
|
return COLOR_LIGHTRED;
|
|
|
|
|
|
|
|
case (T_type::LikeFood):
|
|
|
|
return COLOR_GREEN;
|
|
|
|
|
|
|
|
case (T_type::LikeItem):
|
|
|
|
return COLOR_YELLOW;
|
|
|
|
|
|
|
|
case (T_type::LikeMaterial):
|
|
|
|
return COLOR_CYAN;
|
|
|
|
|
|
|
|
case (T_type::LikePlant):
|
|
|
|
return COLOR_BROWN;
|
|
|
|
|
|
|
|
case (T_type::LikeShape):
|
|
|
|
return COLOR_BLUE;
|
|
|
|
|
|
|
|
case (T_type::LikeTree):
|
|
|
|
return COLOR_BROWN;
|
|
|
|
|
|
|
|
case (T_type::LikeColor):
|
|
|
|
return COLOR_BLUE;
|
|
|
|
|
2018-01-17 23:06:55 -07:00
|
|
|
case (T_type::LikePoeticForm):
|
|
|
|
case (T_type::LikeMusicalForm):
|
|
|
|
case (T_type::LikeDanceForm):
|
|
|
|
return COLOR_LIGHTCYAN;
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
default:
|
2018-01-17 23:07:20 -07:00
|
|
|
return COLOR_LIGHTMAGENTA;
|
2014-05-04 04:45:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void populateDwarfColumn()
|
|
|
|
{
|
|
|
|
dwarf_column.clear();
|
|
|
|
if (preferences_column.getDisplayListSize() > 0)
|
|
|
|
{
|
|
|
|
auto selected_preference = preferences_column.getFirstSelectedElem();
|
|
|
|
for (auto dfit = preferences_store[selected_preference].dwarves.begin();
|
|
|
|
dfit != preferences_store[selected_preference].dwarves.end();
|
|
|
|
dfit++)
|
|
|
|
{
|
|
|
|
string label = getUnitName(*dfit);
|
|
|
|
auto happy = get_happiness_cat(*dfit);
|
|
|
|
UIColor color = monitor_colors[happy];
|
|
|
|
switch (happy)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
label += " (miserable)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
label += " (very unhappy)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
label += " (unhappy)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
label += " (fine)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
label += " (quite content)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
label += " (happy)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
label += " (ecstatic)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ListEntry<df::unit *> elem(label, *dfit, "", color);
|
|
|
|
dwarf_column.add(elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dwarf_column.clearSearch();
|
|
|
|
dwarf_column.setHighlight(0);
|
|
|
|
}
|
|
|
|
|
2018-01-17 23:06:03 -07:00
|
|
|
df::unit *getSelectedUnit() override
|
|
|
|
{
|
|
|
|
return (selected_column == 1) ? dwarf_column.getFirstSelectedElem() : nullptr;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
void feed(set<df::interface_key> *input) override {
|
2014-05-04 04:45:48 -06:00
|
|
|
bool key_processed = false;
|
|
|
|
switch (selected_column)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
key_processed = preferences_column.feed(input);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
key_processed = dwarf_column.feed(input);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_processed)
|
|
|
|
{
|
|
|
|
if (selected_column == 0 && preferences_column.feed_changed_highlight)
|
|
|
|
{
|
|
|
|
populateDwarfColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input->count(interface_key::LEAVESCREEN))
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-18 08:17:54 -07:00
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_V))
|
|
|
|
{
|
|
|
|
df::unit *unit = getSelectedUnit();
|
|
|
|
if (unit)
|
|
|
|
{
|
|
|
|
auto unitscr = df::allocate<df::viewscreen_unitst>();
|
|
|
|
unitscr->unit = unit;
|
2018-06-14 08:12:06 -06:00
|
|
|
Screen::show(std::unique_ptr<df::viewscreen>(unitscr));
|
2018-01-18 08:17:54 -07:00
|
|
|
}
|
|
|
|
}
|
2014-05-04 04:45:48 -06:00
|
|
|
else if (input->count(interface_key::CUSTOM_SHIFT_Z))
|
|
|
|
{
|
2018-01-17 23:06:03 -07:00
|
|
|
df::unit *selected_unit = getSelectedUnit();
|
2014-05-04 04:45:48 -06:00
|
|
|
if (selected_unit)
|
|
|
|
{
|
|
|
|
input->clear();
|
|
|
|
Screen::dismiss(this);
|
|
|
|
Gui::resetDwarfmodeView(true);
|
|
|
|
send_key(interface_key::D_VIEWUNIT);
|
|
|
|
move_cursor(selected_unit->pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CURSOR_LEFT))
|
|
|
|
{
|
|
|
|
--selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (input->count(interface_key::CURSOR_RIGHT))
|
|
|
|
{
|
|
|
|
++selected_column;
|
|
|
|
validateColumn();
|
|
|
|
}
|
|
|
|
else if (enabler->tracking_on && enabler->mouse_lbut)
|
|
|
|
{
|
|
|
|
if (preferences_column.setHighlightByMouse())
|
|
|
|
{
|
|
|
|
selected_column = 0;
|
|
|
|
populateDwarfColumn();
|
|
|
|
}
|
|
|
|
else if (dwarf_column.setHighlightByMouse())
|
|
|
|
selected_column = 1;
|
|
|
|
|
|
|
|
enabler->mouse_lbut = enabler->mouse_rbut = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
void render() override {
|
2018-01-17 23:13:08 -07:00
|
|
|
using namespace df::enums::interface_key;
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
if (Screen::isDismissed(this))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dfhack_viewscreen::render();
|
|
|
|
|
|
|
|
Screen::clear();
|
|
|
|
Screen::drawBorder(" Dwarf Preferences ");
|
|
|
|
|
|
|
|
preferences_column.display(selected_column == 0);
|
|
|
|
dwarf_column.display(selected_column == 1);
|
|
|
|
|
|
|
|
int32_t y = gps->dimy - 3;
|
|
|
|
int32_t x = 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Leave", LEAVESCREEN);
|
2014-05-04 04:45:48 -06:00
|
|
|
|
2018-01-18 08:17:54 -07:00
|
|
|
x += 2;
|
|
|
|
OutputHotkeyString(x, y, "View Unit", CUSTOM_SHIFT_V, false, 0,
|
|
|
|
getSelectedUnit() ? COLOR_WHITE : COLOR_DARKGREY);
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
x += 2;
|
2018-01-17 23:13:08 -07:00
|
|
|
OutputHotkeyString(x, y, "Zoom Unit", CUSTOM_SHIFT_Z, false, 0,
|
|
|
|
getSelectedUnit() ? COLOR_WHITE : COLOR_DARKGREY);
|
2014-05-04 04:45:48 -06:00
|
|
|
}
|
|
|
|
|
2023-01-27 11:22:52 -07:00
|
|
|
std::vector<std::string> getFocusStrings() override { return std::vector<std::string>{"dwarfmonitor_preferences"}; }
|
2014-05-04 04:45:48 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
ListColumn<size_t> preferences_column;
|
|
|
|
ListColumn<df::unit *> dwarf_column;
|
|
|
|
int selected_column;
|
|
|
|
|
|
|
|
map<size_t, size_t> preference_totals;
|
|
|
|
|
|
|
|
vector<preference_map> preferences_store;
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
void validateColumn() {
|
2014-05-04 04:45:48 -06:00
|
|
|
set_to_limit(selected_column, 1);
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
void resize(int32_t x, int32_t y) override {
|
2014-05-04 04:45:48 -06:00
|
|
|
dfhack_viewscreen::resize(x, y);
|
|
|
|
preferences_column.resize();
|
|
|
|
dwarf_column.resize();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static void open_stats_screen() {
|
2018-06-14 08:12:06 -06:00
|
|
|
Screen::show(dts::make_unique<ViewscreenFortStats>(), plugin_self);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static void add_work_history(df::unit *unit, activity_type type) {
|
|
|
|
if (work_history.find(unit) == work_history.end()) {
|
2013-02-15 16:10:47 -07:00
|
|
|
auto max_history = get_max_history();
|
|
|
|
for (int i = 0; i < max_history; i++)
|
|
|
|
work_history[unit].push_back(JOB_UNKNOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
work_history[unit].push_back(type);
|
|
|
|
work_history[unit].pop_front();
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static bool is_at_leisure(df::unit *unit) {
|
2018-11-24 12:52:26 -07:00
|
|
|
if (Units::getMiscTrait(unit, misc_trait_type::Migrant))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!unit->job.current_job && Units::getMainSocialActivity(unit))
|
|
|
|
return true;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static void reset() {
|
2013-02-15 16:10:47 -07:00
|
|
|
work_history.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_dwarf_stats(bool is_paused)
|
|
|
|
{
|
2022-11-02 13:40:18 -06:00
|
|
|
for (auto unit : world->units.active) {
|
2013-02-15 16:10:47 -07:00
|
|
|
if (!Units::isCitizen(unit))
|
|
|
|
continue;
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
if (!DFHack::Units::isActive(unit)) {
|
2013-02-15 16:10:47 -07:00
|
|
|
auto it = work_history.find(unit);
|
|
|
|
if (it != work_history.end())
|
|
|
|
work_history.erase(it);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
if (is_paused)
|
2013-02-15 16:10:47 -07:00
|
|
|
continue;
|
|
|
|
|
2015-01-28 14:26:17 -07:00
|
|
|
if (Units::isBaby(unit) ||
|
2022-11-02 13:40:18 -06:00
|
|
|
Units::isChild(unit) ||
|
|
|
|
unit->profession == profession::DRUNK)
|
2013-03-15 04:50:29 -06:00
|
|
|
continue;
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
if (ENUM_ATTR(profession, military, unit->profession)) {
|
2013-02-15 16:10:47 -07:00
|
|
|
add_work_history(unit, JOB_MILITARY);
|
2013-03-02 01:58:36 -07:00
|
|
|
continue;
|
|
|
|
}
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
if (!unit->job.current_job) {
|
2013-02-15 16:10:47 -07:00
|
|
|
add_work_history(unit, JOB_IDLE);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
if (is_at_leisure(unit)) {
|
2013-02-15 16:10:47 -07:00
|
|
|
add_work_history(unit, JOB_LEISURE);
|
|
|
|
continue;
|
|
|
|
}
|
2014-11-08 12:54:28 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
add_work_history(unit, unit->job.current_job->job_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-04 04:45:48 -06:00
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
DFhackCExport command_result plugin_onupdate (color_ostream &out) {
|
|
|
|
if (!is_enabled | !Maps::IsValid())
|
2013-02-15 16:10:47 -07:00
|
|
|
return CR_OK;
|
|
|
|
|
2013-03-15 23:25:02 -06:00
|
|
|
bool is_paused = DFHack::World::ReadPauseState();
|
2022-11-02 13:40:18 -06:00
|
|
|
if (!is_paused && world->frame_counter % DELTA_TICKS != 0)
|
|
|
|
return CR_OK;
|
2013-02-15 16:10:47 -07:00
|
|
|
|
|
|
|
update_dwarf_stats(is_paused);
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
DFhackCExport command_result plugin_enable(color_ostream &, bool enable) {
|
|
|
|
if (is_enabled != enable) {
|
2013-09-30 03:19:51 -06:00
|
|
|
reset();
|
|
|
|
is_enabled = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
static command_result dwarfmonitor_cmd(color_ostream &, vector <string> & parameters) {
|
2013-02-15 16:10:47 -07:00
|
|
|
if (parameters.empty())
|
2022-11-02 13:40:18 -06:00
|
|
|
return CR_WRONG_USAGE;
|
2013-09-30 03:19:51 -06:00
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
auto cmd = parameters[0][0];
|
|
|
|
if (cmd == 's' || cmd == 'S') {
|
|
|
|
CoreSuspender guard;
|
|
|
|
if(Maps::IsValid())
|
|
|
|
Screen::show(dts::make_unique<ViewscreenFortStats>(), plugin_self);
|
2013-02-15 16:10:47 -07:00
|
|
|
}
|
2022-11-02 13:40:18 -06:00
|
|
|
else if (cmd == 'p' || cmd == 'P') {
|
|
|
|
CoreSuspender guard;
|
|
|
|
if(Maps::IsValid())
|
|
|
|
Screen::show(dts::make_unique<ViewscreenPreferences>(), plugin_self);
|
|
|
|
}
|
|
|
|
else
|
2013-02-15 16:10:47 -07:00
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
DFhackCExport command_result plugin_init(color_ostream &, std::vector <PluginCommand> &commands)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
2013-03-02 01:58:36 -07:00
|
|
|
activity_labels[JOB_IDLE] = "Idle";
|
|
|
|
activity_labels[JOB_MILITARY] = "Military Duty";
|
|
|
|
activity_labels[JOB_LEISURE] = "Leisure";
|
|
|
|
activity_labels[JOB_UNPRODUCTIVE] = "Unproductive";
|
|
|
|
activity_labels[JOB_DESIGNATE] = "Mining";
|
|
|
|
activity_labels[JOB_STORE_ITEM] = "Store/Fetch Item";
|
|
|
|
activity_labels[JOB_MANUFACTURE] = "Manufacturing";
|
|
|
|
activity_labels[JOB_DETAILING] = "Detailing";
|
|
|
|
activity_labels[JOB_HUNTING] = "Hunting/Gathering";
|
|
|
|
activity_labels[JOB_MEDICAL] = "Medical";
|
|
|
|
activity_labels[JOB_COLLECT] = "Collect Materials";
|
|
|
|
activity_labels[JOB_CONSTRUCTION] = "Construction";
|
|
|
|
activity_labels[JOB_AGRICULTURE] = "Agriculture";
|
|
|
|
activity_labels[JOB_FOOD_PROD] = "Food/Drink Production";
|
|
|
|
activity_labels[JOB_MECHANICAL] = "Mechanics";
|
|
|
|
activity_labels[JOB_ANIMALS] = "Animal Handling";
|
|
|
|
activity_labels[JOB_PRODUCTIVE] = "Other Productive";
|
2014-11-08 12:54:28 -07:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
commands.push_back(
|
|
|
|
PluginCommand(
|
2022-07-25 00:08:44 -06:00
|
|
|
"dwarfmonitor",
|
2022-07-25 00:10:25 -06:00
|
|
|
"Measure fort happiness and efficiency.",
|
2022-07-25 00:08:44 -06:00
|
|
|
dwarfmonitor_cmd));
|
2013-02-15 16:10:47 -07:00
|
|
|
|
2015-06-13 15:13:09 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2022-11-02 13:40:18 -06:00
|
|
|
DFhackCExport command_result plugin_onstatechange(color_ostream &, state_change_event event)
|
2013-02-15 16:10:47 -07:00
|
|
|
{
|
2022-11-02 13:40:18 -06:00
|
|
|
if (event == SC_MAP_LOADED)
|
2013-02-15 16:10:47 -07:00
|
|
|
reset();
|
2022-11-02 13:40:18 -06:00
|
|
|
|
2013-02-15 16:10:47 -07:00
|
|
|
return CR_OK;
|
|
|
|
}
|