diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index c8b401e..24af7a4 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -106,21 +106,22 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener template auto drawUnsafeWidget(Functor func, Args... args) -> bool { - if(!_unsafeMode && _mbManager->gameState() != GameState::NotRunning) { + GameState game_state = _mbManager->gameState(); + if(!_unsafeMode && game_state != GameState::NotRunning) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f); } bool result = func(std::forward(args)...); - if(!_unsafeMode && _mbManager->gameState() != GameState::NotRunning) { + if(!_unsafeMode && game_state != GameState::NotRunning) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } return result; } // Obviously, should only be used with ImGui widgets that return a bool. - // Also, should be called with a lambda if there are any default arguments, like ImGui::Button(), etc... + // Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc... void drawUnsafeText(const char* text, ...); // Alternative to the above, for ImGui::Text*() variants.