SaveTool: replace varargs with templates in drawUnsafeText().
This commit is contained in:
parent
fa78ca2a8a
commit
a16383183e
2 changed files with 9 additions and 14 deletions
|
@ -17,7 +17,6 @@
|
|||
#include "SaveTool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <Corrade/Utility/FormatStl.h>
|
||||
#include <Corrade/Utility/String.h>
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<typename... Args>
|
||||
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>(args)...);
|
||||
}
|
||||
else {
|
||||
ImGui::Text(text, std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
void openUri(const std::string& uri);
|
||||
|
||||
|
|
Loading…
Reference in a new issue