From e2d31854b44f5228fef03c9feebe990f9350b934 Mon Sep 17 00:00:00 2001 From: William JCM Date: Fri, 11 Mar 2022 09:20:24 +0100 Subject: [PATCH] SaveTool: use ImGui's {Begin,End}Disabled API. --- src/SaveTool/SaveTool.h | 6 ++---- src/SaveTool/SaveTool_MainManager.cpp | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index fb30fe3..a4b49b2 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -161,15 +161,13 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener auto drawUnsafeWidget(Functor func, Args... args) -> bool { GameState game_state = _gameState; // Copying the value to reduce the risk of a data race. if(!_unsafeMode && game_state != GameState::NotRunning) { - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f); + ImGui::BeginDisabled(); } bool result = func(std::forward(args)...); if(!_unsafeMode && game_state != GameState::NotRunning) { - ImGui::PopItemFlag(); - ImGui::PopStyleVar(); + ImGui::EndDisabled(); } return result; diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/SaveTool/SaveTool_MainManager.cpp index 8545e9e..2882741 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/SaveTool/SaveTool_MainManager.cpp @@ -150,8 +150,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { !(len >= 6 && len <= 32) || !(name_view[0] != ' ' && name_view[len - 1] != ' ')) { - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f); + ImGui::BeginDisabled(); } if(ImGui::Button("Apply")) { @@ -163,8 +162,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { !(len >= 6 && len <= 32) || !(name_view[0] != ' ' && name_view[len - 1] != ' ')) { - ImGui::PopItemFlag(); - ImGui::PopStyleVar(); + ImGui::EndDisabled(); } ImGui::EndPopup();