From 0ef0bca80eb93495a154fe0e19c05079673250e8 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 14 Apr 2022 16:29:23 -0400 Subject: [PATCH] Big macOS changes pt. 1 There's a new "Game" menu where you can install the game if you missed the initial prompt on start-up. If you have XIV on Mac (a fellow XIV launcher) installed, you now have the option of using their wine binaries and libraries. There is more to come in future commits, especially pertaining DXVK and MoltenVK. Game installation has been fixed for macOS, enabling you to start updating right away without having to fiddle around with finding the right installer or app package. --- external/libxiv | 2 +- include/gameinstaller.h | 3 ++- include/launchercore.h | 3 ++- src/gameinstaller.cpp | 6 +++--- src/launchercore.cpp | 15 +++++++++++++-- src/launcherwindow.cpp | 33 +++++++++++++++++++++++++++++++++ src/main.cpp | 2 +- src/settingswindow.cpp | 1 + 8 files changed, 56 insertions(+), 9 deletions(-) diff --git a/external/libxiv b/external/libxiv index 0e653bf..58a24f0 160000 --- a/external/libxiv +++ b/external/libxiv @@ -1 +1 @@ -Subproject commit 0e653bf6e95b7633b3f0a55217d82cf799b4a289 +Subproject commit 58a24f08b86ea41e5c5b4cb18ec104b9ad872118 diff --git a/include/gameinstaller.h b/include/gameinstaller.h index a1947e5..63003f7 100644 --- a/include/gameinstaller.h +++ b/include/gameinstaller.h @@ -4,6 +4,7 @@ #include class LauncherCore; +class ProfileSettings; // TODO: convert to a nice signal/slots class like assetupdater -void installGame(LauncherCore& launcher, std::function returnFunc); \ No newline at end of file +void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function returnFunc); \ No newline at end of file diff --git a/include/launchercore.h b/include/launchercore.h index 58ec0b0..8555402 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -24,7 +24,8 @@ enum class GameLicense { enum class WineType { System, Custom, - Builtin // macos only + Builtin, // macos only + XIVOnMac // macos only }; enum class DalamudChannel { diff --git a/src/gameinstaller.cpp b/src/gameinstaller.cpp index e439150..9a8a199 100644 --- a/src/gameinstaller.cpp +++ b/src/gameinstaller.cpp @@ -7,8 +7,8 @@ #include "launchercore.h" -void installGame(LauncherCore& launcher, std::function returnFunc) { - QString installDirectory = launcher.getProfile(launcher.defaultProfileIndex).gamePath; +void installGame(LauncherCore& launcher, ProfileSettings& profile, std::function returnFunc) { + QString installDirectory = profile.gamePath; qDebug() << "Installing game to " << installDirectory << "!"; qDebug() << "Now downloading installer file..."; @@ -27,7 +27,7 @@ void installGame(LauncherCore& launcher, std::function returnFunc) { extractBootstrapFiles((dataDir + "/ffxivsetup.exe").toStdString(), installDirectory.toStdString()); - qDebug() << "Done installing!"; + qDebug() << "Done installing to " << installDirectory << "!"; returnFunc(); }); diff --git a/src/launchercore.cpp b/src/launchercore.cpp index d9b9059..1463a43 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -250,6 +250,14 @@ void LauncherCore::launchExecutable(const ProfileSettings& profile, QProcess* pr #if defined(Q_OS_MAC) || defined(Q_OS_LINUX) env.insert("WINEPREFIX", profile.winePrefixPath); + // XIV on Mac bundle their own Wine install directory, complete with libs etc + if(profile.wineType == WineType::XIVOnMac) { + // TODO: don't hardcode this + QString xivLibPath = "/Applications/XIV on Mac.app/Contents/Resources/wine/lib"; + + env.insert("DYLD_FALLBACK_LIBRARY_PATH", xivLibPath); + } + arguments.push_back(profile.winePath); #endif @@ -354,8 +362,6 @@ void LauncherCore::readInitialInformation() { profile.name = settings.value("name", "Default").toString(); - readWineInfo(profile); - if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !settings.value("gamePath").toString().isEmpty()) { profile.gamePath = settings.value("gamePath").toString(); } else { @@ -389,6 +395,8 @@ void LauncherCore::readInitialInformation() { profile.wineType = (WineType)settings.value("wineType", (int)defaultSettings.wineType).toInt(); profile.useEsync = settings.value("useEsync", defaultSettings.useEsync).toBool(); + readWineInfo(profile); + if(gamescopeAvailable) profile.useGamescope = settings.value("useGamescope", defaultSettings.useGamescope).toBool(); @@ -430,6 +438,9 @@ void LauncherCore::readWineInfo(ProfileSettings& profile) { case WineType::Builtin: // ffxiv built-in (for mac users) profile.winePath = "/Applications/FINAL FANTASY XIV ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine"; break; + case WineType::XIVOnMac: + profile.winePath = "/Applications/XIV on Mac.app/Contents/Resources/wine/bin/wine64"; + break; } #endif diff --git a/src/launcherwindow.cpp b/src/launcherwindow.cpp index e0f844f..19ae174 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -17,6 +17,7 @@ #include "headline.h" #include "config.h" #include "aboutwindow.h" +#include "gameinstaller.h" LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) { setWindowTitle("Astra"); @@ -51,6 +52,38 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo openPath(currentProfile().gamePath); }); + QMenu* gameMenu = menuBar()->addMenu("Game"); + + auto installGameAction = gameMenu->addAction("Install game..."); + connect(installGameAction, &QAction::triggered, [this] { + // TODO: lol duplication + auto messageBox = new QMessageBox(this); + messageBox->setIcon(QMessageBox::Icon::Question); + messageBox->setText("Warning"); + messageBox->setInformativeText("FFXIV will be installed to your selected game directory."); + + QString detailedText = QString("Astra will install FFXIV for you at '%1'").arg(this->currentProfile().gamePath); + detailedText.append("\n\nIf you do not wish to install it to this location, please change your profile settings."); + + messageBox->setDetailedText(detailedText); + messageBox->setWindowModality(Qt::WindowModal); + + auto installButton = messageBox->addButton("Install Game", QMessageBox::YesRole); + connect(installButton, &QPushButton::clicked, [this, messageBox] { + installGame(this->core, this->currentProfile(), [this, messageBox] { + this->core.readGameVersion(); + + messageBox->close(); + + }); + }); + + messageBox->addButton(QMessageBox::StandardButton::No); + messageBox->setDefaultButton(installButton); + + messageBox->exec(); + }); + QMenu* fileMenu = menuBar()->addMenu("Settings"); QAction* settingsAction = fileMenu->addAction("Configure Astra..."); diff --git a/src/main.cpp b/src/main.cpp index b5c69f1..ece7c72 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) { auto installButton = messageBox->addButton("Install Game", QMessageBox::YesRole); c.connect(installButton, &QPushButton::clicked, [&c, messageBox] { - installGame(c, [messageBox, &c] { + installGame(c, c.getProfile(c.defaultProfileIndex), [messageBox, &c] { c.readGameVersion(); messageBox->close(); diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index f5785ef..3139492 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -264,6 +264,7 @@ SettingsWindow::SettingsWindow(int defaultTab, LauncherWindow& window, LauncherC #if defined(Q_OS_MAC) wineTypeCombo->insertItem(2, "FFXIV Built-In"); + wineTypeCombo->insertItem(3, "XIV on Mac"); #endif wineTypeCombo->insertItem(0, "System Wine");