diff --git a/library/Core.cpp b/library/Core.cpp index 63357b145..a932e49e7 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1721,6 +1721,14 @@ void Core::doUpdate(color_ostream &out, bool first_update) screen = screen->child; } + // detect if the viewscreen changed, and trigger events later + bool vs_changed = false; + if (screen != top_viewscreen) + { + top_viewscreen = screen; + vs_changed = true; + } + bool is_load_save = strict_virtual_cast(screen) || strict_virtual_cast(screen) || @@ -1770,12 +1778,8 @@ void Core::doUpdate(color_ostream &out, bool first_update) } } - // detect if the viewscreen changed - if (screen != top_viewscreen) - { - top_viewscreen = screen; + if (vs_changed) onStateChange(out, SC_VIEWSCREEN_CHANGED); - } if (df::global::pause_state) {