SaveTool: clean things up a bit.

This commit is contained in:
Guillaume Jacquemin 2022-11-21 20:37:28 +01:00
parent 7ddc8e0748
commit c5b4747685
4 changed files with 32 additions and 29 deletions

View File

@ -49,9 +49,9 @@ SaveTool::SaveTool(const Arguments& arguments):
Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION " (\"" SAVETOOL_CODENAME "\")") Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION " (\"" SAVETOOL_CODENAME "\")")
.setSize({960, 720})} .setSize({960, 720})}
{ {
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
tweak.enable(""_s, "../../"_s); tweak.enable(""_s, "../../"_s);
#endif #endif
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
GL::Renderer::enable(GL::Renderer::Feature::ScissorTest); GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);
@ -195,9 +195,9 @@ SaveTool::~SaveTool() {
} }
void SaveTool::drawEvent() { void SaveTool::drawEvent() {
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
tweak.update(); tweak.update();
#endif #endif
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
@ -298,7 +298,7 @@ void SaveTool::drawGui() {
drawAbout(); drawAbout();
} }
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
if(_demoWindow) { if(_demoWindow) {
ImGui::ShowDemoWindow(&_demoWindow); ImGui::ShowDemoWindow(&_demoWindow);
} }
@ -310,7 +310,7 @@ void SaveTool::drawGui() {
if(_metricsWindow) { if(_metricsWindow) {
ImGui::ShowMetricsWindow(&_metricsWindow); ImGui::ShowMetricsWindow(&_metricsWindow);
} }
#endif #endif
_queue.draw(windowSize()); _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::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::Bullet();
ImGui::SameLine(); 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::Bullet();
ImGui::SameLine(); ImGui::SameLine();

View File

@ -38,8 +38,8 @@ void SaveTool::initEvent(SDL_Event& event) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
break; break;
case ProfileManagerFailure: case ProfileManagerFailure:
Utility::Error{} << "Error initialising ProfileManager:" << _profileManager->lastError(); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error ",
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().data(), window()); _profileManager->lastError().data(), window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
break; break;
default: default:
@ -102,7 +102,8 @@ void SaveTool::initialiseGui() {
ImFontConfig font_config; ImFontConfig font_config;
font_config.FontDataOwnedByAtlas = false; font_config.FontDataOwnedByAtlas = false;
std::strcpy(font_config.Name, "Source Sans Pro"); std::strcpy(font_config.Name, "Source Sans Pro");
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(reg_font.data()), reg_font.size(), 20.0f, &font_config); io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(reg_font.data()), int(reg_font.size()),
20.0f, &font_config);
auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS); auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS);
static const ImWchar icon_range[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; 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.PixelSnapH = true;
icon_config.OversampleH = icon_config.OversampleV = 1; icon_config.OversampleH = icon_config.OversampleV = 1;
icon_config.GlyphMinAdvanceX = 18.0f; icon_config.GlyphMinAdvanceX = 18.0f;
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(icon_font.data()), icon_font.size(), 16.0f, &icon_config, icon_range); io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(icon_font.data()), int(icon_font.size()),
16.0f, &icon_config, icon_range);
auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB); auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB);
static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 }; static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 };
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), brand_font.size(), 16.0f, &icon_config, brand_range); io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), int(brand_font.size()),
16.0f, &icon_config, brand_range);
auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s); auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s);
ImVector<ImWchar> range; ImVector<ImWchar> range;
@ -124,7 +127,8 @@ void SaveTool::initialiseGui() {
builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); builder.AddRanges(io.Fonts->GetGlyphRangesDefault());
builder.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences. builder.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences.
builder.BuildRanges(&range); builder.BuildRanges(&range);
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(mono_font.data()), mono_font.size(), 18.0f, &font_config, range.Data); io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(mono_font.data()), int(mono_font.size()),
18.0f, &font_config, range.Data);
_imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize()); _imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize());

View File

@ -17,7 +17,6 @@
#include "SaveTool.h" #include "SaveTool.h"
#include <Corrade/version.h> #include <Corrade/version.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/version.h> #include <Magnum/version.h>
#include <Magnum/versionIntegration.h> #include <Magnum/versionIntegration.h>
@ -32,7 +31,7 @@ extern const ImVec2 center_pivot;
void SaveTool::drawAbout() { void SaveTool::drawAbout() {
ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); 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"); ImGui::OpenPopup("About##AboutPopup");
if(!ImGui::BeginPopupModal("About##AboutPopup", &_aboutPopup, if(!ImGui::BeginPopupModal("About##AboutPopup", &_aboutPopup,
@ -84,7 +83,7 @@ void SaveTool::drawAbout() {
if(ImGui::CollapsingHeader("Licence")) { 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:"); 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"); static auto licence = _rs.getRaw("COPYING");
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None); ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None);
@ -114,7 +113,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto corrade_licence = _rs.getRaw("COPYING.Corrade"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -142,7 +141,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto magnum_licence = _rs.getRaw("COPYING.Magnum"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -168,7 +167,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto imgui_licence = _rs.getRaw("LICENSE.ImGui"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -194,7 +193,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: zlib"); ImGui::TextUnformatted("Licence: zlib");
static auto sdl_licence = _rs.getRaw("LICENSE.SDL"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -220,7 +219,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: 3-clause BSD"); ImGui::TextUnformatted("Licence: 3-clause BSD");
static auto libzip_licence = _rs.getRaw("LICENSE.libzip"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -245,7 +244,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto efsw_licence = _rs.getRaw("LICENSE.efsw"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();
@ -270,7 +269,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT/X derivative"); ImGui::TextUnformatted("Licence: MIT/X derivative");
static auto curl_licence = _rs.getRaw("LICENSE.curl"); 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::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None); ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None);
ImGui::PopFont(); ImGui::PopFont();

View File

@ -58,8 +58,8 @@ void SaveTool::drawMainMenu() {
drawAlignedText("Frame limiter:"); drawAlignedText("Frame limiter:");
ImGui::SameLine(); ImGui::SameLine();
static UnsignedByte selection = static_cast<UnsignedByte>(_framelimit);
static const char* framelimit_labels[3] = { static const char* framelimit_labels[3] = {
static auto selection = static_cast<UnsignedByte>(_framelimit);
"V-sync", "V-sync",
"Half V-sync", "Half V-sync",
"FPS cap, no V-sync" "FPS cap, no V-sync"
@ -149,11 +149,11 @@ void SaveTool::drawMainMenu() {
if(ImGui::BeginMenu(ICON_FA_DISCORD " Discord communities")) { if(ImGui::BeginMenu(ICON_FA_DISCORD " Discord communities")) {
if(ImGui::MenuItem("Official server")) { if(ImGui::MenuItem("Official server")) {
openUri("https://discord.gg/quS7E46"); openUri("https://discord.gg/sekai-project");
} }
if(ImGui::MenuItem("Community server")) { if(ImGui::MenuItem("Community server")) {
openUri("https://discord.gg/YSSRTRB"); openUri("https://discord.gg/massbuildercommunity");
} }
ImGui::EndMenu(); ImGui::EndMenu();
@ -162,7 +162,7 @@ void SaveTool::drawMainMenu() {
ImGui::EndMenu(); ImGui::EndMenu();
} }
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
if(ImGui::BeginMenu("Debug tools")) { if(ImGui::BeginMenu("Debug tools")) {
ImGui::MenuItem("ImGui demo window", nullptr, &_demoWindow); ImGui::MenuItem("ImGui demo window", nullptr, &_demoWindow);
ImGui::MenuItem("ImGui style editor", nullptr, &_styleEditor); ImGui::MenuItem("ImGui style editor", nullptr, &_styleEditor);
@ -170,7 +170,7 @@ void SaveTool::drawMainMenu() {
ImGui::EndMenu(); ImGui::EndMenu();
} }
#endif #endif
if(ImGui::BeginMenu("Help")) { if(ImGui::BeginMenu("Help")) {
if(ImGui::BeginMenu(ICON_FA_KEYBOARD " Keyboard shortcuts")) { if(ImGui::BeginMenu(ICON_FA_KEYBOARD " Keyboard shortcuts")) {