SaveTool: improve drawUnsafeWidget().
This commit is contained in:
parent
031b7a1c9a
commit
f9a3088094
1 changed files with 4 additions and 3 deletions
|
@ -106,21 +106,22 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
template<typename Functor, typename... Args>
|
template<typename Functor, typename... Args>
|
||||||
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
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::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = func(std::forward<Args>(args)...);
|
bool result = func(std::forward<Args>(args)...);
|
||||||
|
|
||||||
if(!_unsafeMode && _mbManager->gameState() != GameState::NotRunning) {
|
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
||||||
ImGui::PopItemFlag();
|
ImGui::PopItemFlag();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} // Obviously, should only be used with ImGui widgets that return a bool.
|
} // 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.
|
void drawUnsafeText(const char* text, ...); // Alternative to the above, for ImGui::Text*() variants.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue