2021-06-11 19:24:52 +02:00
|
|
|
// MassBuilderSaveTool
|
2023-09-02 18:30:29 +02:00
|
|
|
// Copyright (C) 2021-2023 Guillaume Jacquemin
|
2021-06-11 19:24:52 +02:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2022-03-09 11:04:19 +01:00
|
|
|
#include <Corrade/Utility/Path.h>
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
#include "../Configuration/Configuration.h"
|
2021-06-11 19:24:52 +02:00
|
|
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
|
|
|
#include "../FontAwesome/IconsFontAwesome5Brands.h"
|
|
|
|
|
2022-12-01 23:39:53 +01:00
|
|
|
#include "SaveTool.h"
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
|
|
|
SaveTool::drawMainMenu() {
|
2022-12-01 23:42:39 +01:00
|
|
|
if(!ImGui::BeginMainMenuBar()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
|
|
|
|
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open game data directory", Utility::Path::exists(_gameDataDir))) {
|
|
|
|
if(ImGui::MenuItem(ICON_FA_COG " Configuration", nullptr, false, Utility::Path::exists(_configDir))) {
|
|
|
|
openUri(Utility::Path::toNativeSeparators(_configDir));
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::MenuItem(ICON_FA_SAVE " Saves", nullptr, false, Utility::Path::exists(_saveDir))) {
|
|
|
|
openUri(Utility::Path::toNativeSeparators(_saveDir));
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::MenuItem(ICON_FA_IMAGE " Screenshots", nullptr, false, Utility::Path::exists(_screenshotsDir))) {
|
|
|
|
openUri(Utility::Path::toNativeSeparators(_screenshotsDir));
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-07-10 16:45:25 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open manager directory")) {
|
|
|
|
if(ImGui::MenuItem(ICON_FA_FILE_ARCHIVE " Profile backups", nullptr, false, Utility::Path::exists(_backupsDir))) {
|
|
|
|
openUri(Utility::Path::toNativeSeparators(_backupsDir));
|
|
|
|
}
|
2021-07-21 20:57:39 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::MenuItem(ICON_FA_EXCHANGE_ALT " Staging area", nullptr, false, Utility::Path::exists(_stagingDir))) {
|
|
|
|
openUri(Utility::Path::toNativeSeparators(_stagingDir));
|
2021-07-10 16:45:25 +02:00
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::Separator();
|
2022-11-30 10:03:45 +01:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
drawAlignedText("Vertical sync:");
|
|
|
|
if(conf().swapInterval() == 0) {
|
|
|
|
drawAlignedText("FPS cap:");
|
|
|
|
}
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
|
|
|
static const char* framelimit_labels[] = {
|
|
|
|
"Off",
|
|
|
|
"Every VBLANK",
|
|
|
|
"Every second VBLANK",
|
|
|
|
"Every third VBLANK",
|
|
|
|
};
|
2021-08-18 16:53:29 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::PushItemWidth(300.0f);
|
|
|
|
|
|
|
|
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[conf().swapInterval()])) {
|
|
|
|
for(int i = 0; i <= 3; i++) {
|
|
|
|
if(ImGui::Selectable(framelimit_labels[i], conf().swapInterval() == i)) {
|
|
|
|
conf().setSwapInterval(i);
|
|
|
|
setSwapInterval(i);
|
|
|
|
if(i == 0) {
|
|
|
|
setMinimalLoopPeriod(0);
|
2022-11-30 10:03:45 +01:00
|
|
|
}
|
2021-08-18 16:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(conf().swapInterval() == 0) {
|
|
|
|
static float fps_cap = conf().fpsCap();
|
|
|
|
if(ImGui::SliderFloat("##FpsCapSlider", &fps_cap, 15.0f, 301.0f,
|
|
|
|
conf().fpsCap() != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp))
|
|
|
|
{
|
|
|
|
conf().setFpsCap(fps_cap);
|
2022-11-30 10:03:45 +01:00
|
|
|
}
|
2022-12-01 23:42:39 +01:00
|
|
|
}
|
2022-11-30 10:03:45 +01:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::PopItemWidth();
|
2022-11-30 10:03:45 +01:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndGroup();
|
2022-11-30 10:03:45 +01:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(drawCheckbox("Cheat mode", conf().cheatMode())) {
|
|
|
|
conf().setCheatMode(!conf().cheatMode());
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::AlignTextToFramePadding();
|
|
|
|
drawHelpMarker("This gives access to save edition features that can be considered cheats.",
|
2022-12-05 11:32:18 +01:00
|
|
|
float(windowSize().x()) * 0.4f);
|
2021-07-28 15:00:15 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(drawCheckbox("Advanced mode", conf().advancedMode())) {
|
|
|
|
conf().setAdvancedMode(!conf().advancedMode());
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::AlignTextToFramePadding();
|
|
|
|
drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.",
|
2022-12-05 11:32:18 +01:00
|
|
|
float(windowSize().x()) * 0.4f);
|
2022-11-25 17:10:56 +01:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(drawCheckbox("Check for updates on startup", conf().checkUpdatesOnStartup())) {
|
|
|
|
conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup());
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
|
|
|
|
_queue.addToast(Toast::Type::Default, "Checking for updates...");
|
|
|
|
_updateThread = std::thread{[this]{ checkForUpdates(); }};
|
|
|
|
}
|
2021-07-23 14:17:42 +02:00
|
|
|
|
2023-10-29 15:42:15 +01:00
|
|
|
if(_checker && _checkerMutex.try_lock()) {
|
|
|
|
if(_checker->updateAvailable()) {
|
|
|
|
drawAlignedText("Version %s is available.", Containers::String{_checker->version()}.data());
|
|
|
|
if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) {
|
|
|
|
openUri("https://williamjcm.ovh/mbst");
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button(ICON_FA_DOWNLOAD " Download now")) {
|
|
|
|
openUri(_checker->downloadLink());
|
|
|
|
}
|
2021-07-28 14:18:39 +02:00
|
|
|
}
|
2023-10-29 11:32:17 +01:00
|
|
|
_checkerMutex.unlock();
|
2021-07-22 11:39:53 +02:00
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(drawCheckbox("Skip disclaimer", conf().skipDisclaimer())) {
|
|
|
|
conf().setSkipDisclaimer(!conf().skipDisclaimer());
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::Separator();
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::MenuItem(ICON_FA_SIGN_OUT_ALT " Quit##QuitMenuItem")) {
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2023-08-31 12:34:34 +02:00
|
|
|
ImGui::BeginDisabled(conf().isRunningInWine());
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::BeginMenu("Game##GameMenu")) {
|
|
|
|
if(ImGui::MenuItem(ICON_FA_PLAY " Run demo##RunDemoMenuItem")) {
|
|
|
|
openUri("steam://run/1048390");
|
|
|
|
}
|
|
|
|
drawTooltip("Will not work if you have the full game.");
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(ImGui::MenuItem(ICON_FA_PLAY " Run full game##RunFullGameMenuItem")) {
|
|
|
|
openUri("steam://run/956680");
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
if(ImGui::BeginMenu(ICON_FA_DISCORD " Discord communities")) {
|
|
|
|
if(ImGui::MenuItem("Official server")) {
|
|
|
|
openUri("https://discord.gg/sekai-project");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ImGui::MenuItem("Community server")) {
|
|
|
|
openUri("https://discord.gg/massbuildercommunity");
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2023-08-31 12:34:34 +02:00
|
|
|
ImGui::EndDisabled();
|
|
|
|
if(conf().isRunningInWine() && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
|
|
|
ImGui::SetTooltip("Not available when running in Wine.");
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
#ifdef SAVETOOL_DEBUG_BUILD
|
|
|
|
if(ImGui::BeginMenu("Debug tools")) {
|
|
|
|
ImGui::MenuItem("ImGui demo window", nullptr, &_demoWindow);
|
|
|
|
ImGui::MenuItem("ImGui style editor", nullptr, &_styleEditor);
|
|
|
|
ImGui::MenuItem("ImGui metrics window", nullptr, &_metricsWindow);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(ImGui::BeginMenu("Help")) {
|
|
|
|
if(ImGui::BeginMenu(ICON_FA_KEYBOARD " Keyboard shortcuts")) {
|
|
|
|
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
|
|
|
|
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
|
|
|
|
ImGui::BulletText("While inputing text:\n");
|
|
|
|
ImGui::Indent();
|
|
|
|
ImGui::BulletText("CTRL+Left/Right to word jump.");
|
|
|
|
ImGui::BulletText("CTRL+A or double-click to select all.");
|
|
|
|
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
|
|
|
|
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
|
|
|
|
ImGui::BulletText("ESCAPE to revert.");
|
|
|
|
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
|
|
|
|
ImGui::Unindent();
|
2021-06-11 19:24:52 +02:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::MenuItem(ICON_FA_INFO_CIRCLE " About", nullptr, &_aboutPopup);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
if(_gameCheckTimerId != 0) {
|
|
|
|
if(ImGui::BeginTable("##MainMenuLayout", 2)) {
|
|
|
|
ImGui::TableSetupColumn("##Dummy", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
ImGui::TableSetupColumn("##GameState", ImGuiTableColumnFlags_WidthFixed);
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
drawGameState();
|
2021-06-11 19:24:52 +02:00
|
|
|
|
2022-12-01 23:42:39 +01:00
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|
2022-12-01 23:42:39 +01:00
|
|
|
|
|
|
|
ImGui::EndMainMenuBar();
|
2021-06-11 19:24:52 +02:00
|
|
|
}
|