SaveTool: use ImGui's {Begin,End}Disabled API.
This commit is contained in:
parent
ccf630c385
commit
e2d31854b4
2 changed files with 4 additions and 8 deletions
|
@ -161,15 +161,13 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
||||||
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
|
GameState game_state = _gameState; // Copying the value to reduce the risk of a data race.
|
||||||
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
||||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
ImGui::BeginDisabled();
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = func(std::forward<Args>(args)...);
|
bool result = func(std::forward<Args>(args)...);
|
||||||
|
|
||||||
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
||||||
ImGui::PopItemFlag();
|
ImGui::EndDisabled();
|
||||||
ImGui::PopStyleVar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -150,8 +150,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
|
||||||
!(len >= 6 && len <= 32) ||
|
!(len >= 6 && len <= 32) ||
|
||||||
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
|
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
|
||||||
{
|
{
|
||||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
ImGui::BeginDisabled();
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::Button("Apply")) {
|
if(ImGui::Button("Apply")) {
|
||||||
|
@ -163,8 +162,7 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView<char> name_view) -> bool {
|
||||||
!(len >= 6 && len <= 32) ||
|
!(len >= 6 && len <= 32) ||
|
||||||
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
|
!(name_view[0] != ' ' && name_view[len - 1] != ' '))
|
||||||
{
|
{
|
||||||
ImGui::PopItemFlag();
|
ImGui::EndDisabled();
|
||||||
ImGui::PopStyleVar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
|
Loading…
Reference in a new issue