Fix confirm performance

develop
Robob27 2023-02-17 18:41:20 -05:00
parent 180d10dd32
commit 5244fce469
2 changed files with 17 additions and 11 deletions

@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
-@ `autochop`: generate default names for burrows with no assigned names -@ `autochop`: generate default names for burrows with no assigned names
- ``Buildings::StockpileIterator``: check for stockpile items on block boundary. - ``Buildings::StockpileIterator``: check for stockpile items on block boundary.
- `tailor`: block making clothing sized for toads; make replacement clothing orders use the size of the wearer, not the size of the garment; add support for adamantine cloth (off by default); improve logging - `tailor`: block making clothing sized for toads; make replacement clothing orders use the size of the wearer, not the size of the garment; add support for adamantine cloth (off by default); improve logging
- `confirm`: fix fps drop when enabled
## Misc Improvements ## Misc Improvements
- DFHack tool windows that capture mouse clicks (and therefore prevent you from clicking on the "pause" button) now unconditionally pause the game when they open (but you can still unpause with the keyboard if you want to). Examples of this behavior: `gui/quickfort`, `gui/blueprint`, `gui/liquids` - DFHack tool windows that capture mouse clicks (and therefore prevent you from clicking on the "pause" button) now unconditionally pause the game when they open (but you can still unpause with the keyboard if you want to). Examples of this behavior: `gui/quickfort`, `gui/blueprint`, `gui/liquids`

@ -66,6 +66,7 @@ bool set_conf_paused (string name, bool pause);
class confirmation_base { class confirmation_base {
public: public:
bool dirty = false;
enum cstate { INACTIVE, ACTIVE, SELECTED }; enum cstate { INACTIVE, ACTIVE, SELECTED };
virtual string get_id() = 0; virtual string get_id() = 0;
virtual string get_focus_string() = 0; virtual string get_focus_string() = 0;
@ -281,6 +282,7 @@ public:
} }
state = s; state = s;
dirty = true;
if (s == INACTIVE) { if (s == INACTIVE) {
active_id = ""; active_id = "";
confirmation_base::active = nullptr; confirmation_base::active = nullptr;
@ -371,6 +373,8 @@ public:
return state == ACTIVE; return state == ACTIVE;
} }
void render() { void render() {
if (state == ACTIVE)
{
static vector<string> lines; static vector<string> lines;
static const std::string pause_message = static const std::string pause_message =
"Pause confirmations until you exit this screen"; "Pause confirmations until you exit this screen";
@ -380,8 +384,7 @@ public:
Screen::Pen corner_dr = Screen::Pen((char)188, COLOR_GREY, COLOR_BLACK); Screen::Pen corner_dr = Screen::Pen((char)188, COLOR_GREY, COLOR_BLACK);
Screen::Pen border_ud = Screen::Pen((char)205, COLOR_GREY, COLOR_BLACK); Screen::Pen border_ud = Screen::Pen((char)205, COLOR_GREY, COLOR_BLACK);
Screen::Pen border_lr = Screen::Pen((char)186, COLOR_GREY, COLOR_BLACK); Screen::Pen border_lr = Screen::Pen((char)186, COLOR_GREY, COLOR_BLACK);
if (state == ACTIVE)
{
split_string(&lines, get_message(), "\n"); split_string(&lines, get_message(), "\n");
size_t max_length = 40; size_t max_length = 40;
for (string line : lines) for (string line : lines)
@ -463,9 +466,11 @@ public:
} }
set_state(INACTIVE); set_state(INACTIVE);
} }
// clean up any artifacts if(dirty) {
dirty = false;
df::global::gps->force_full_display_count = 1; df::global::gps->force_full_display_count = 1;
} }
}
string get_id() override = 0; string get_id() override = 0;
string get_focus_string() override = 0; string get_focus_string() override = 0;
#define CONF_LUA_START using namespace conf_lua; Lua::StackUnwinder unwind(l_state); push(screen); push(get_id()); #define CONF_LUA_START using namespace conf_lua; Lua::StackUnwinder unwind(l_state); push(screen); push(get_id());