From a16383183ec88485190b1196de0c03635329b380 Mon Sep 17 00:00:00 2001 From: William JCM Date: Wed, 21 Jul 2021 13:40:55 +0200 Subject: [PATCH] SaveTool: replace varargs with templates in drawUnsafeText(). --- src/SaveTool/SaveTool.cpp | 13 ------------- src/SaveTool/SaveTool.h | 10 +++++++++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 086c8a8..ebf3cd1 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -17,7 +17,6 @@ #include "SaveTool.h" #include -#include #include #include @@ -487,18 +486,6 @@ void SaveTool::drawTooltip(const char* text, Float wrap_pos) { } } -void SaveTool::drawUnsafeText(const char* text, ...) { - va_list args; - va_start(args, text); - if(!_unsafeMode && _mbManager->gameState() != GameState::NotRunning) { - ImGui::TextDisabledV(text, args); - } - else { - ImGui::TextV(text, args); - } - va_end(args); -} - void SaveTool::openUri(const std::string& uri) { ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri).c_str(), nullptr, nullptr, SW_SHOW); } diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index c6ab344..b03eea0 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -123,7 +123,15 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener } // Obviously, should only be used with ImGui widgets that return a bool. // 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. + template + void drawUnsafeText(const char* text, Args... args) { // Alternative to the above, for ImGui::Text*() variants. + if(!_unsafeMode && _mbManager->gameState() != GameState::NotRunning) { + ImGui::TextDisabled(text, std::forward(args)...); + } + else { + ImGui::Text(text, std::forward(args)...); + } + } void openUri(const std::string& uri);