main,SaveTool,Configuration: further Wine support.

This commit is contained in:
Guillaume Jacquemin 2023-08-31 12:34:34 +02:00
parent a1a155d0ac
commit f7a8962194
Signed by: williamjcm
SSH Key Fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A
5 changed files with 36 additions and 3 deletions

View File

@ -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{};

View File

@ -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();

View File

@ -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

View File

@ -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")) {

View File

@ -22,6 +22,7 @@
#include <synchapi.h>
#include <winerror.h>
#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");