SaveTool: use ImGui's {Begin,End}Disabled API.

This commit is contained in:
Guillaume Jacquemin 2022-03-11 09:20:24 +01:00
parent ccf630c385
commit e2d31854b4
2 changed files with 4 additions and 8 deletions

View File

@ -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>(args)...);
if(!_unsafeMode && game_state != GameState::NotRunning) {
ImGui::PopItemFlag();
ImGui::PopStyleVar();
ImGui::EndDisabled();
}
return result;

View File

@ -150,8 +150,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> 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<char> name_view) -> bool {
!(len >= 6 && len <= 32) ||
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
{
ImGui::PopItemFlag();
ImGui::PopStyleVar();
ImGui::EndDisabled();
}
ImGui::EndPopup();