From c5b474768532c75985b6220cef20843a0a1fb4cb Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 20:37:28 +0100 Subject: [PATCH] SaveTool: clean things up a bit. --- src/SaveTool/SaveTool.cpp | 16 ++++++++-------- src/SaveTool/SaveTool_Initialisation.cpp | 16 ++++++++++------ src/SaveTool/SaveTool_drawAbout.cpp | 19 +++++++++---------- src/SaveTool/SaveTool_drawMainMenu.cpp | 10 +++++----- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 7fcd49c..80f31ae 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -49,9 +49,9 @@ SaveTool::SaveTool(const Arguments& arguments): Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION " (\"" SAVETOOL_CODENAME "\")") .setSize({960, 720})} { -#ifdef SAVETOOL_DEBUG_BUILD + #ifdef SAVETOOL_DEBUG_BUILD tweak.enable(""_s, "../../"_s); -#endif + #endif GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::ScissorTest); @@ -195,9 +195,9 @@ SaveTool::~SaveTool() { } void SaveTool::drawEvent() { -#ifdef SAVETOOL_DEBUG_BUILD + #ifdef SAVETOOL_DEBUG_BUILD tweak.update(); -#endif + #endif GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); @@ -298,7 +298,7 @@ void SaveTool::drawGui() { drawAbout(); } -#ifdef SAVETOOL_DEBUG_BUILD + #ifdef SAVETOOL_DEBUG_BUILD if(_demoWindow) { ImGui::ShowDemoWindow(&_demoWindow); } @@ -310,7 +310,7 @@ void SaveTool::drawGui() { if(_metricsWindow) { ImGui::ShowMetricsWindow(&_metricsWindow); } -#endif + #endif _queue.draw(windowSize()); } @@ -329,11 +329,11 @@ void SaveTool::drawDisclaimer() { ImGui::TextUnformatted("Before you start using the app, there are a few things you should know:"); - ImGui::PushTextWrapPos(windowSize().x() * 0.67f); + ImGui::PushTextWrapPos(float(windowSize().x()) * 0.67f); ImGui::Bullet(); ImGui::SameLine(); - ImGui::TextUnformatted("For this application to work properly, it is recommended to disable Steam Cloud syncing for the game. To disable it, right-click the game in your Steam library, click \"Properties\", go to the \"General\" tab, and uncheck \"Keep game saves in the Steam Cloud for M.A.S.S. Builder\"."); + ImGui::TextUnformatted(R"(For this application to work properly, it is recommended to disable Steam Cloud syncing for the game. To disable it, right-click the game in your Steam library, click "Properties", go to the "General" tab, and uncheck "Keep game saves in the Steam Cloud for M.A.S.S. Builder".)"); ImGui::Bullet(); ImGui::SameLine(); diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index a40a12c..94465a1 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -38,8 +38,8 @@ void SaveTool::initEvent(SDL_Event& event) { ImGui::CloseCurrentPopup(); break; case ProfileManagerFailure: - Utility::Error{} << "Error initialising ProfileManager:" << _profileManager->lastError(); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().data(), window()); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error ", + _profileManager->lastError().data(), window()); exit(EXIT_FAILURE); break; default: @@ -102,7 +102,8 @@ void SaveTool::initialiseGui() { ImFontConfig font_config; font_config.FontDataOwnedByAtlas = false; std::strcpy(font_config.Name, "Source Sans Pro"); - io.Fonts->AddFontFromMemoryTTF(const_cast(reg_font.data()), reg_font.size(), 20.0f, &font_config); + io.Fonts->AddFontFromMemoryTTF(const_cast(reg_font.data()), int(reg_font.size()), + 20.0f, &font_config); auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS); static const ImWchar icon_range[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; @@ -112,11 +113,13 @@ void SaveTool::initialiseGui() { icon_config.PixelSnapH = true; icon_config.OversampleH = icon_config.OversampleV = 1; icon_config.GlyphMinAdvanceX = 18.0f; - io.Fonts->AddFontFromMemoryTTF(const_cast(icon_font.data()), icon_font.size(), 16.0f, &icon_config, icon_range); + io.Fonts->AddFontFromMemoryTTF(const_cast(icon_font.data()), int(icon_font.size()), + 16.0f, &icon_config, icon_range); auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB); static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 }; - io.Fonts->AddFontFromMemoryTTF(const_cast(brand_font.data()), brand_font.size(), 16.0f, &icon_config, brand_range); + io.Fonts->AddFontFromMemoryTTF(const_cast(brand_font.data()), int(brand_font.size()), + 16.0f, &icon_config, brand_range); auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s); ImVector range; @@ -124,7 +127,8 @@ void SaveTool::initialiseGui() { builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); builder.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences. builder.BuildRanges(&range); - io.Fonts->AddFontFromMemoryTTF(const_cast(mono_font.data()), mono_font.size(), 18.0f, &font_config, range.Data); + io.Fonts->AddFontFromMemoryTTF(const_cast(mono_font.data()), int(mono_font.size()), + 18.0f, &font_config, range.Data); _imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize()); diff --git a/src/SaveTool/SaveTool_drawAbout.cpp b/src/SaveTool/SaveTool_drawAbout.cpp index 95f0009..b80af38 100644 --- a/src/SaveTool/SaveTool_drawAbout.cpp +++ b/src/SaveTool/SaveTool_drawAbout.cpp @@ -17,7 +17,6 @@ #include "SaveTool.h" #include -#include #include #include @@ -32,7 +31,7 @@ extern const ImVec2 center_pivot; void SaveTool::drawAbout() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); - ImGui::SetNextWindowSize({windowSize().x() * 0.8f, windowSize().y() * 0.75f}, ImGuiCond_Always); + ImGui::SetNextWindowSize({float(windowSize().x()) * 0.8f, float(windowSize().y()) * 0.75f}, ImGuiCond_Always); ImGui::OpenPopup("About##AboutPopup"); if(!ImGui::BeginPopupModal("About##AboutPopup", &_aboutPopup, @@ -84,7 +83,7 @@ void SaveTool::drawAbout() { if(ImGui::CollapsingHeader("Licence")) { ImGui::TextWrapped("This application is made available under the terms of the GNU General Public License, version 3, the full text of which is available below:"); - if(ImGui::BeginChild("##GPL", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, true)) { static auto licence = _rs.getRaw("COPYING"); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None); @@ -114,7 +113,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: MIT"); static auto corrade_licence = _rs.getRaw("COPYING.Corrade"); - if(ImGui::BeginChild("##CorradeLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##CorradeLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -142,7 +141,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: MIT"); static auto magnum_licence = _rs.getRaw("COPYING.Magnum"); - if(ImGui::BeginChild("##MagnumLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##MagnumLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -168,7 +167,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: MIT"); static auto imgui_licence = _rs.getRaw("LICENSE.ImGui"); - if(ImGui::BeginChild("##ImGuiLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##ImGuiLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -194,7 +193,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: zlib"); static auto sdl_licence = _rs.getRaw("LICENSE.SDL"); - if(ImGui::BeginChild("##SDLLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##SDLLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -220,7 +219,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: 3-clause BSD"); static auto libzip_licence = _rs.getRaw("LICENSE.libzip"); - if(ImGui::BeginChild("##libzipLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##libzipLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -245,7 +244,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: MIT"); static auto efsw_licence = _rs.getRaw("LICENSE.efsw"); - if(ImGui::BeginChild("##efswLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##efswLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); @@ -270,7 +269,7 @@ void SaveTool::drawAbout() { ImGui::TextUnformatted("Licence: MIT/X derivative"); static auto curl_licence = _rs.getRaw("LICENSE.curl"); - if(ImGui::BeginChild("##libcurlLicence", {0.0f, windowSize().y() * 0.3f}, true)) { + if(ImGui::BeginChild("##libcurlLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None); ImGui::PopFont(); diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index 0c51eb8..0ec6a1a 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -58,8 +58,8 @@ void SaveTool::drawMainMenu() { drawAlignedText("Frame limiter:"); ImGui::SameLine(); - static UnsignedByte selection = static_cast(_framelimit); static const char* framelimit_labels[3] = { + static auto selection = static_cast(_framelimit); "V-sync", "Half V-sync", "FPS cap, no V-sync" @@ -149,11 +149,11 @@ void SaveTool::drawMainMenu() { if(ImGui::BeginMenu(ICON_FA_DISCORD " Discord communities")) { if(ImGui::MenuItem("Official server")) { - openUri("https://discord.gg/quS7E46"); + openUri("https://discord.gg/sekai-project"); } if(ImGui::MenuItem("Community server")) { - openUri("https://discord.gg/YSSRTRB"); + openUri("https://discord.gg/massbuildercommunity"); } ImGui::EndMenu(); @@ -162,7 +162,7 @@ void SaveTool::drawMainMenu() { ImGui::EndMenu(); } -#ifdef SAVETOOL_DEBUG_BUILD + #ifdef SAVETOOL_DEBUG_BUILD if(ImGui::BeginMenu("Debug tools")) { ImGui::MenuItem("ImGui demo window", nullptr, &_demoWindow); ImGui::MenuItem("ImGui style editor", nullptr, &_styleEditor); @@ -170,7 +170,7 @@ void SaveTool::drawMainMenu() { ImGui::EndMenu(); } -#endif + #endif if(ImGui::BeginMenu("Help")) { if(ImGui::BeginMenu(ICON_FA_KEYBOARD " Keyboard shortcuts")) {