From 5244fce4696bb45dec8474a5774ff2ffb543e7f9 Mon Sep 17 00:00:00 2001 From: Robob27 Date: Fri, 17 Feb 2023 18:41:20 -0500 Subject: [PATCH] Fix confirm performance --- docs/changelog.txt | 1 + plugins/confirm.cpp | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index bf168ac3a..93aca95f8 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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 - ``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 +- `confirm`: fix fps drop when enabled ## 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` diff --git a/plugins/confirm.cpp b/plugins/confirm.cpp index a15b83055..1dfb6809d 100644 --- a/plugins/confirm.cpp +++ b/plugins/confirm.cpp @@ -66,6 +66,7 @@ bool set_conf_paused (string name, bool pause); class confirmation_base { public: + bool dirty = false; enum cstate { INACTIVE, ACTIVE, SELECTED }; virtual string get_id() = 0; virtual string get_focus_string() = 0; @@ -281,6 +282,7 @@ public: } state = s; + dirty = true; if (s == INACTIVE) { active_id = ""; confirmation_base::active = nullptr; @@ -371,17 +373,18 @@ public: return state == ACTIVE; } void render() { - static vector lines; - static const std::string pause_message = - "Pause confirmations until you exit this screen"; - Screen::Pen corner_ul = Screen::Pen((char)201, COLOR_GREY, COLOR_BLACK); - Screen::Pen corner_ur = Screen::Pen((char)187, COLOR_GREY, COLOR_BLACK); - Screen::Pen corner_dl = Screen::Pen((char)200, 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_lr = Screen::Pen((char)186, COLOR_GREY, COLOR_BLACK); if (state == ACTIVE) { + static vector lines; + static const std::string pause_message = + "Pause confirmations until you exit this screen"; + Screen::Pen corner_ul = Screen::Pen((char)201, COLOR_GREY, COLOR_BLACK); + Screen::Pen corner_ur = Screen::Pen((char)187, COLOR_GREY, COLOR_BLACK); + Screen::Pen corner_dl = Screen::Pen((char)200, 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_lr = Screen::Pen((char)186, COLOR_GREY, COLOR_BLACK); + split_string(&lines, get_message(), "\n"); size_t max_length = 40; for (string line : lines) @@ -463,8 +466,10 @@ public: } set_state(INACTIVE); } - // clean up any artifacts - df::global::gps->force_full_display_count = 1; + if(dirty) { + dirty = false; + df::global::gps->force_full_display_count = 1; + } } string get_id() override = 0; string get_focus_string() override = 0;