diff --git a/include/launchercore.h b/include/launchercore.h index f68e26e..394bf40 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -47,10 +47,6 @@ struct ProfileSettings { int refreshRate = 0; } gamescope; - QString dalamudVersion; // TODO: move out of profile settings - int dalamudAssetVersion = -1; - QString runtimeVersion; - // login bool encryptArguments = true; bool isSapphire = false; @@ -131,6 +127,10 @@ public: AppSettings appSettings; + QString dalamudVersion; + int dalamudAssetVersion = -1; + QString runtimeVersion; + int defaultProfileIndex = 0; signals: void settingsChanged(); diff --git a/src/assetupdater.cpp b/src/assetupdater.cpp index c5c8821..7277456 100644 --- a/src/assetupdater.cpp +++ b/src/assetupdater.cpp @@ -53,14 +53,14 @@ void AssetUpdater::update(const ProfileSettings& profile) { return; } else { - if (profile.dalamudVersion != remoteDalamudVersion) { + if (launcher.dalamudVersion != remoteDalamudVersion) { isDalamudUpdated = false; } else { qInfo() << "No need to update Dalamud."; isDalamudUpdated = true; } - if(profile.runtimeVersion != remoteRuntimeVersion) { + if(launcher.runtimeVersion != remoteRuntimeVersion) { doneDownloadingRuntimeCore = false; doneDownloadingRuntimeDesktop = false; needsRuntimeInstall = true; @@ -126,11 +126,11 @@ void AssetUpdater::update(const ProfileSettings& profile) { QJsonDocument doc = QJsonDocument::fromJson(badJson.toUtf8()); qInfo() << "Dalamud asset remote version" << doc.object()["Version"].toInt(); - qInfo() << "Dalamud asset local version" << profile.dalamudAssetVersion; + qInfo() << "Dalamud asset local version" << launcher.dalamudAssetVersion; remoteDalamudAssetVersion = doc.object()["Version"].toInt(); - if(remoteDalamudAssetVersion != profile.dalamudAssetVersion) { + if(remoteDalamudAssetVersion != launcher.dalamudAssetVersion) { qInfo() << "Dalamud assets out of date."; dalamudAssetNeededFilenames.clear(); @@ -184,7 +184,7 @@ void AssetUpdater::update(const ProfileSettings& profile) { }); } - if(remoteDalamudVersion != profile.dalamudVersion) { + if(remoteDalamudVersion != launcher.dalamudVersion) { qInfo() << "Downloading Dalamud..."; doneDownloadingDalamud = false; needsDalamudInstall = true; diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 73070af..5f8d0b4 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -263,6 +263,41 @@ void LauncherCore::readInitialInformation() { gamescopeAvailable = checkIfInPath("gamescope"); gamemodeAvailable = checkIfInPath("gamemoderun"); + const QString dataDir = + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + + const bool hasDalamud = QFile::exists(dataDir + "/Dalamud"); + if (hasDalamud) { + if (QFile::exists(dataDir + "/Dalamud/Dalamud.deps.json")) { + QFile depsJson(dataDir + "/Dalamud/Dalamud.deps.json"); + depsJson.open(QFile::ReadOnly); + QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll()); + + // TODO: UGLY + QString versionString = + doc["targets"] + .toObject()[".NETCoreApp,Version=v5.0"] + .toObject() + .keys() + .filter("Dalamud")[0]; + dalamudVersion = versionString.remove("Dalamud/"); + } + + if(QFile::exists(dataDir + "/DalamudAssets/asset.ver")) { + QFile assetJson(dataDir + "/DalamudAssets/asset.ver"); + assetJson.open(QFile::ReadOnly | QFile::Text); + + dalamudAssetVersion = QString(assetJson.readAll()).toInt(); + } + + if(QFile::exists(dataDir + "/DalamudRuntime/runtime.ver")) { + QFile runtimeVer(dataDir + "/DalamudRuntime/runtime.ver"); + runtimeVer.open(QFile::ReadOnly | QFile::Text); + + runtimeVersion = QString(runtimeVer.readAll()); + } + } + auto profiles = settings.childGroups(); // create the Default profile if it doesnt exist @@ -282,41 +317,6 @@ void LauncherCore::readInitialInformation() { readWineInfo(profile); - const QString dataDir = - QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - - const bool hasDalamud = QFile::exists(dataDir + "/Dalamud"); - if (hasDalamud) { - if (QFile::exists(dataDir + "/Dalamud/Dalamud.deps.json")) { - QFile depsJson(dataDir + "/Dalamud/Dalamud.deps.json"); - depsJson.open(QFile::ReadOnly); - QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll()); - - // TODO: UGLY - QString versionString = - doc["targets"] - .toObject()[".NETCoreApp,Version=v5.0"] - .toObject() - .keys() - .filter("Dalamud")[0]; - profile.dalamudVersion = versionString.remove("Dalamud/"); - } - - if(QFile::exists(dataDir + "/DalamudAssets/asset.ver")) { - QFile assetJson(dataDir + "/DalamudAssets/asset.ver"); - assetJson.open(QFile::ReadOnly | QFile::Text); - - profile.dalamudAssetVersion = QString(assetJson.readAll()).toInt(); - } - - if(QFile::exists(dataDir + "/DalamudRuntime/runtime.ver")) { - QFile runtimeVer(dataDir + "/DalamudRuntime/runtime.ver"); - runtimeVer.open(QFile::ReadOnly | QFile::Text); - - profile.runtimeVersion = QString(runtimeVer.readAll()); - } - } - if(settings.contains("gamePath") && settings.value("gamePath").canConvert() && !settings.value("gamePath").toString().isEmpty()) { profile.gamePath = settings.value("gamePath").toString(); } else { diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index e074812..a20050c 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -475,16 +475,16 @@ void SettingsWindow::reloadControls() { // dalamud enableDalamudBox->setChecked(profile.enableDalamud); - if(profile.dalamudVersion.isEmpty()) { + if(core.dalamudVersion.isEmpty()) { dalamudVersionLabel->setText("Dalamud is not installed."); } else { - dalamudVersionLabel->setText(profile.dalamudVersion); + dalamudVersionLabel->setText(core.dalamudVersion); } - if(profile.dalamudAssetVersion == -1) { + if(core.dalamudAssetVersion == -1) { dalamudAssetVersionLabel->setText("Dalamud assets are not installed."); } else { - dalamudAssetVersionLabel->setText(QString::number(profile.dalamudAssetVersion)); + dalamudAssetVersionLabel->setText(QString::number(core.dalamudAssetVersion)); } window.reloadControls();