diff --git a/src/Configuration/Configuration.cpp b/src/Configuration/Configuration.cpp index c1a4545..61a86bd 100644 --- a/src/Configuration/Configuration.cpp +++ b/src/Configuration/Configuration.cpp @@ -156,6 +156,14 @@ Configuration::setSkipDisclaimer(bool mode) { _conf.save(); } +bool Configuration::isRunningInWine() const { + return _isRunningInWine; +} + +void Configuration::setRunningInWine(bool wine) { + _isRunningInWine = wine; +} + Configuration& Configuration::instance() { static Configuration conf{}; diff --git a/src/Configuration/Configuration.h b/src/Configuration/Configuration.h index 5b9a0ca..884e522 100644 --- a/src/Configuration/Configuration.h +++ b/src/Configuration/Configuration.h @@ -46,6 +46,9 @@ class Configuration { bool skipDisclaimer() const; void setSkipDisclaimer(bool mode); + bool isRunningInWine() const; + void setRunningInWine(bool wine); + private: explicit Configuration(); @@ -57,6 +60,8 @@ class Configuration { bool _advancedMode = false; bool _checkUpdatesOnStartup = true; bool _skipDisclaimer = false; + + bool _isRunningInWine = false; }; Configuration& conf(); diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 7d2a009..7fd17bf 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -337,6 +337,12 @@ SaveTool::drawDisclaimer() { ImGui::SameLine(); ImGui::TextUnformatted("This version of the application was tested on M.A.S.S. Builder early access version " SUPPORTED_GAME_VERSION ". It may or may not work with other versions of the game."); + if(conf().isRunningInWine()) { + ImGui::Bullet(); + ImGui::SameLine(); + ImGui::TextUnformatted("You are currently running this application in Wine/Proton. It hasn't been fully tested, so some issues may arise. Furthermore, features may be unavailable."); + } + ImGui::PopTextWrapPos(); if(ImGui::BeginTable("##DisclaimerLayoutTable", 3)) { @@ -430,9 +436,12 @@ SaveTool::drawCheckbox(Containers::StringView label, bool value) { void SaveTool::openUri(Containers::StringView uri) { - ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT); - // TODO: have it open folders through winebrowser.exe when running using Wine/Proton. - // URLs like Discord invites or Steam Browser Protocol links should be disabled entirely there. + if(!conf().isRunningInWine()) { + ShellExecuteA(nullptr, nullptr, uri.data(), nullptr, nullptr, SW_SHOWDEFAULT); + } + else { + std::system(Utility::format("winebrowser.exe {}", uri).cbegin()); + } } void diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index b204087..2e74919 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -159,6 +159,7 @@ SaveTool::drawMainMenu() { ImGui::EndMenu(); } + ImGui::BeginDisabled(conf().isRunningInWine()); if(ImGui::BeginMenu("Game##GameMenu")) { if(ImGui::MenuItem(ICON_FA_PLAY " Run demo##RunDemoMenuItem")) { openUri("steam://run/1048390"); @@ -185,6 +186,10 @@ SaveTool::drawMainMenu() { ImGui::EndMenu(); } + ImGui::EndDisabled(); + if(conf().isRunningInWine() && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { + ImGui::SetTooltip("Not available when running in Wine."); + } #ifdef SAVETOOL_DEBUG_BUILD if(ImGui::BeginMenu("Debug tools")) { diff --git a/src/main.cpp b/src/main.cpp index 13e958c..e76d422 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ #include #include +#include "Configuration/Configuration.h" #include "Logger/MagnumLogBuffer.h" #include "SaveTool/SaveTool.h" @@ -50,6 +51,11 @@ int main(int argc, char** argv) { "Your system doesn't support UTF-8.", nullptr); return EXIT_FAILURE; } + + if(locale.hasSuffix(".65001")) { + LOG_INFO("Wine detected."); + conf().setRunningInWine(true); + } } auto mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");