diff --git a/README.rst b/README.rst
index 9e3d5d3f9..c6b0509e1 100644
--- a/README.rst
+++ b/README.rst
@@ -1510,6 +1510,10 @@ The following mouse shortcuts are also available:
* Left-click on a unit's name or profession to view its properties.
* Right-click on a unit's name or profession to zoom to it.
+Pressing ESC normally returns to the unit screen, but Shift-ESC would exit
+directly to the main dwarf mode screen.
+
+
Liquids
=======
diff --git a/Readme.html b/Readme.html
index 7b41dc74b..fcf7dab6a 100644
--- a/Readme.html
+++ b/Readme.html
@@ -2395,6 +2395,8 @@ cursor onto that cell instead of toggling it.
Left-click on a unit's name or profession to view its properties.
Right-click on a unit's name or profession to zoom to it.
+Pressing ESC normally returns to the unit screen, but Shift-ESC would exit
+directly to the main dwarf mode screen.
diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp
index 033ad8b85..a3ec72a47 100644
--- a/plugins/manipulator.cpp
+++ b/plugins/manipulator.cpp
@@ -331,6 +331,12 @@ class viewscreen_unitlaborsst : public dfhack_viewscreen {
public:
void feed(set
*events);
+ void logic() {
+ dfhack_viewscreen::logic();
+ if (do_refresh_names)
+ refreshNames();
+ }
+
void render();
void resize(int w, int h) { calcSize(); }
@@ -347,12 +353,14 @@ protected:
vector units;
altsort_mode altsort;
+ bool do_refresh_names;
int first_row, sel_row, num_rows;
int first_column, sel_column;
int col_widths[DISP_COLUMN_MAX];
int col_offsets[DISP_COLUMN_MAX];
+ void refreshNames();
void calcSize ();
};
@@ -377,9 +385,6 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur
if (!ENUM_ATTR(profession, can_assign_labor, unit->profession))
cur->allowEdit = false;
- cur->name = Translation::TranslateName(&unit->name, false);
- cur->transname = Translation::TranslateName(&unit->name, true);
- cur->profession = Units::getProfessionName(unit);
cur->color = Units::getProfessionColor(unit);
units.push_back(cur);
@@ -387,6 +392,8 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur
altsort = ALTSORT_NAME;
first_column = sel_column = 0;
+ refreshNames();
+
first_row = 0;
sel_row = cursor_pos;
calcSize();
@@ -403,6 +410,21 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur
first_row = units.size() - num_rows;
}
+void viewscreen_unitlaborsst::refreshNames()
+{
+ do_refresh_names = false;
+
+ for (size_t i = 0; i < units.size(); i++)
+ {
+ UnitInfo *cur = units[i];
+ df::unit *unit = cur->unit;
+
+ cur->name = Translation::TranslateName(&unit->name, false);
+ cur->transname = Translation::TranslateName(&unit->name, true);
+ cur->profession = Units::getProfessionName(unit);
+ }
+}
+
void viewscreen_unitlaborsst::calcSize()
{
num_rows = gps->dimy - 10;
@@ -476,16 +498,25 @@ void viewscreen_unitlaborsst::calcSize()
void viewscreen_unitlaborsst::feed(set *events)
{
- if (events->count(interface_key::LEAVESCREEN))
+ bool leave_all = events->count(interface_key::LEAVESCREEN_ALL);
+ if (leave_all || events->count(interface_key::LEAVESCREEN))
{
events->clear();
Screen::dismiss(this);
+ if (leave_all)
+ {
+ events->insert(interface_key::LEAVESCREEN);
+ parent->feed(events);
+ }
return;
}
if (!units.size())
return;
+ if (do_refresh_names)
+ refreshNames();
+
if (events->count(interface_key::CURSOR_UP) || events->count(interface_key::CURSOR_UPLEFT) || events->count(interface_key::CURSOR_UPRIGHT))
sel_row--;
if (events->count(interface_key::CURSOR_UP_FAST) || events->count(interface_key::CURSOR_UPLEFT_FAST) || events->count(interface_key::CURSOR_UPRIGHT_FAST))
@@ -758,6 +789,8 @@ void viewscreen_unitlaborsst::feed(set *events)
unitlist->feed(events);
if (Screen::isDismissed(unitlist))
Screen::dismiss(this);
+ else
+ do_refresh_names = true;
break;
}
}
@@ -990,6 +1023,9 @@ void viewscreen_unitlaborsst::render()
df::unit *viewscreen_unitlaborsst::getSelectedUnit()
{
+ // This query might be from the rename plugin
+ do_refresh_names = true;
+
return units[sel_row]->unit;
}