2023-08-05 22:14:05 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
#include "profile.h"
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
#include <KLocalizedString>
|
2023-07-30 08:49:34 -04:00
|
|
|
#include <QFile>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
#include "account.h"
|
2023-10-08 18:02:02 -04:00
|
|
|
#include "astra_log.h"
|
2023-07-30 08:49:34 -04:00
|
|
|
#include "launchercore.h"
|
2023-08-18 12:59:07 -04:00
|
|
|
#include "profileconfig.h"
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Profile::Profile(LauncherCore &launcher, const QString &key, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_uuid(key)
|
2023-08-18 12:59:07 -04:00
|
|
|
, m_config(new ProfileConfig(key))
|
2023-07-30 08:49:34 -04:00
|
|
|
, m_launcher(launcher)
|
|
|
|
{
|
|
|
|
readGameVersion();
|
2023-07-31 19:35:53 -04:00
|
|
|
readWineInfo();
|
2023-10-08 18:21:36 -04:00
|
|
|
readDalamudInfo();
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 18:21:36 -04:00
|
|
|
void Profile::readDalamudInfo()
|
|
|
|
{
|
2023-08-18 21:36:29 -04:00
|
|
|
const QDir dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
const QDir dalamudDir = dataDir.absoluteFilePath(QStringLiteral("dalamud"));
|
2023-08-18 21:36:29 -04:00
|
|
|
|
|
|
|
if (dalamudDir.exists()) {
|
|
|
|
const QDir dalamudInstallDir = dalamudDir.absoluteFilePath(dalamudChannelName());
|
2023-09-17 08:51:26 -04:00
|
|
|
const QDir dalamudAssetsDir = dalamudDir.absoluteFilePath(QStringLiteral("assets"));
|
|
|
|
const QDir dalamudRuntimeDir = dalamudDir.absoluteFilePath(QStringLiteral("runtime"));
|
2023-08-18 21:36:29 -04:00
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
const QString dalamudDepsJson = dalamudInstallDir.absoluteFilePath(QStringLiteral("Dalamud.deps.json"));
|
2023-08-18 21:36:29 -04:00
|
|
|
if (QFile::exists(dalamudDepsJson)) {
|
|
|
|
QFile depsJson(dalamudDepsJson);
|
2023-07-30 08:49:34 -04:00
|
|
|
depsJson.open(QFile::ReadOnly);
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(depsJson.readAll());
|
|
|
|
|
|
|
|
QString versionString;
|
2023-09-17 08:51:26 -04:00
|
|
|
for (const auto &target : doc[QLatin1String("targets")].toObject().keys()) {
|
|
|
|
if (target.contains(QLatin1String(".NETCoreApp"))) {
|
|
|
|
versionString = doc[QLatin1String("targets")].toObject()[target].toObject().keys().filter(QStringLiteral("Dalamud/"))[0];
|
2023-07-30 16:20:28 -04:00
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
m_dalamudVersion = versionString.remove(QLatin1String("Dalamud/"));
|
2023-10-08 18:02:02 -04:00
|
|
|
qInfo(ASTRA_LOG) << "Dalamud version:" << m_dalamudVersion;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
const QString dalamudAssetsVer = dalamudAssetsDir.absoluteFilePath(QStringLiteral("asset.ver"));
|
2023-08-18 21:36:29 -04:00
|
|
|
if (QFile::exists(dalamudAssetsVer)) {
|
|
|
|
QFile assetJson(dalamudAssetsVer);
|
2023-07-30 08:49:34 -04:00
|
|
|
assetJson.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
m_dalamudAssetVersion = QString(assetJson.readAll()).toInt();
|
2023-10-08 18:02:02 -04:00
|
|
|
qInfo(ASTRA_LOG) << "Dalamud asset version:" << m_dalamudVersion;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
const QString dalamudRuntimeVer = dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver"));
|
2023-08-18 21:36:29 -04:00
|
|
|
if (QFile::exists(dalamudRuntimeVer)) {
|
|
|
|
QFile runtimeVer(dalamudRuntimeVer);
|
2023-07-30 08:49:34 -04:00
|
|
|
runtimeVer.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
m_runtimeVersion = QString(runtimeVer.readAll());
|
2023-10-08 18:02:02 -04:00
|
|
|
qInfo(ASTRA_LOG) << "Dalamud runtime version:" << m_dalamudVersion;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::readGameData()
|
|
|
|
{
|
2023-09-17 08:51:26 -04:00
|
|
|
physis_EXH *exh = physis_gamedata_read_excel_sheet_header(m_gameData, "ExVersion");
|
2023-07-30 08:49:34 -04:00
|
|
|
if (exh != nullptr) {
|
2023-09-17 08:51:26 -04:00
|
|
|
physis_EXD exd = physis_gamedata_read_excel_sheet(m_gameData, "ExVersion", exh, Language::English, 0);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < exd.row_count; i++) {
|
2023-09-17 08:51:26 -04:00
|
|
|
m_expansionNames.push_back(exd.row_data[i].column_data[0].string._0);
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
physis_gamedata_free_sheet(exd);
|
|
|
|
physis_gamedata_free_sheet_header(exh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::readWineInfo()
|
|
|
|
{
|
|
|
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
|
|
|
|
auto wineProcess = new QProcess(this);
|
|
|
|
|
2023-10-08 13:20:41 -04:00
|
|
|
connect(wineProcess, &QProcess::readyReadStandardOutput, this, [wineProcess, this] {
|
2023-07-30 08:49:34 -04:00
|
|
|
m_wineVersion = wineProcess->readAllStandardOutput().trimmed();
|
2023-09-17 08:51:26 -04:00
|
|
|
Q_EMIT wineChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
});
|
|
|
|
|
2023-10-08 13:20:41 -04:00
|
|
|
wineProcess->start(winePath(), {QStringLiteral("--version")});
|
2023-07-30 08:49:34 -04:00
|
|
|
wineProcess->waitForFinished();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::name() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->name();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setName(const QString &name)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->name() != name) {
|
|
|
|
m_config->setName(name);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT nameChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::gamePath() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamePath();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamePath(const QString &path)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamePath() != path) {
|
|
|
|
m_config->setGamePath(path);
|
|
|
|
m_config->save();
|
2023-10-08 19:14:17 -04:00
|
|
|
readGameVersion();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamePathChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::winePath() const
|
|
|
|
{
|
2023-10-08 13:20:41 -04:00
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
switch (wineType()) {
|
|
|
|
case WineType::System: // system wine
|
|
|
|
return "/usr/local/bin/wine64";
|
|
|
|
case WineType::Custom: // custom path
|
|
|
|
return m_config->winePath();
|
|
|
|
case WineType::Builtin: // ffxiv built-in (for mac users)
|
|
|
|
return "/Applications/FINAL FANTASY XIV "
|
|
|
|
"ONLINE.app/Contents/SharedSupport/finalfantasyxiv/FINAL FANTASY XIV ONLINE/wine";
|
|
|
|
case WineType::XIVOnMac:
|
|
|
|
return "/Applications/XIV on Mac.app/Contents/Resources/wine/bin/wine64";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
switch (wineType()) {
|
|
|
|
case WineType::System: // system wine (should be in $PATH)
|
|
|
|
return QStringLiteral("wine");
|
|
|
|
case WineType::Custom: // custom pth
|
|
|
|
return m_config->winePath();
|
|
|
|
default:
|
2023-10-08 18:21:36 -04:00
|
|
|
return {};
|
2023-10-08 13:20:41 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return {};
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setWinePath(const QString &path)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->winePath() != path) {
|
|
|
|
m_config->setWinePath(path);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT winePathChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::winePrefixPath() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->winePrefixPath();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setWinePrefixPath(const QString &path)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->winePrefixPath() != path) {
|
|
|
|
m_config->setWinePrefixPath(path);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT winePrefixPathChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Profile::WineType Profile::wineType() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return static_cast<WineType>(m_config->wineType());
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setWineType(const WineType type)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (static_cast<WineType>(m_config->wineType()) != type) {
|
|
|
|
m_config->setWineType(static_cast<int>(type));
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT wineTypeChanged();
|
2023-07-31 19:35:53 -04:00
|
|
|
readWineInfo();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::esyncEnabled() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->useESync();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setESyncEnabled(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->useESync() != value) {
|
|
|
|
m_config->setUseESync(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT useESyncChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::gamescopeEnabled() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->useGamescope();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeEnabled(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->useGamescope() != value) {
|
|
|
|
m_config->setUseGamescope(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT useGamescopeChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::gamemodeEnabled() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->useGamemode();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamemodeEnabled(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->useGamemode() != value) {
|
|
|
|
m_config->setUseGamemode(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT useGamemodeChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::directx9Enabled() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->useDX9();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setDirectX9Enabled(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->useDX9() != value) {
|
|
|
|
m_config->setUseDX9(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT useDX9Changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::gamescopeFullscreen() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamescopeFullscreen();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeFullscreen(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamescopeFullscreen() != value) {
|
|
|
|
m_config->setGamescopeFullscreen(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamescopeFullscreenChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::gamescopeBorderless() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamescopeBorderless();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeBorderless(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamescopeBorderless() != value) {
|
|
|
|
m_config->setGamescopeBorderless(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamescopeBorderlessChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::gamescopeWidth() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamescopeWidth();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeWidth(const int value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamescopeWidth() != value) {
|
|
|
|
m_config->setGamescopeWidth(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamescopeWidthChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::gamescopeHeight() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamescopeHeight();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeHeight(const int value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamescopeHeight() != value) {
|
|
|
|
m_config->setGamescopeHeight(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamescopeHeightChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::gamescopeRefreshRate() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->gamescopeRefreshRate();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setGamescopeRefreshRate(const int value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->gamescopeRefreshRate() != value) {
|
|
|
|
m_config->setGamescopeRefreshRate(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT gamescopeRefreshRateChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Profile::dalamudEnabled() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->dalamudEnabled();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setDalamudEnabled(const bool value)
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
if (m_config->dalamudEnabled() != value) {
|
|
|
|
m_config->setDalamudEnabled(value);
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_EMIT dalamudEnabledChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-20 16:28:59 -04:00
|
|
|
Profile::DalamudChannel Profile::dalamudChannel() const
|
2023-07-30 08:49:34 -04:00
|
|
|
{
|
2023-09-20 16:28:59 -04:00
|
|
|
return static_cast<DalamudChannel>(m_config->dalamudChannel());
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-20 16:28:59 -04:00
|
|
|
void Profile::setDalamudChannel(const DalamudChannel value)
|
2023-07-30 08:49:34 -04:00
|
|
|
{
|
2023-09-20 16:28:59 -04:00
|
|
|
if (static_cast<DalamudChannel>(m_config->dalamudChannel()) != value) {
|
|
|
|
m_config->setDalamudChannel(static_cast<int>(value));
|
2023-08-18 12:59:07 -04:00
|
|
|
m_config->save();
|
2023-09-20 16:28:59 -04:00
|
|
|
Q_EMIT dalamudChannelChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-20 16:28:59 -04:00
|
|
|
Profile::DalamudInjectMethod Profile::dalamudInjectMethod() const
|
2023-07-30 08:49:34 -04:00
|
|
|
{
|
2023-09-20 16:28:59 -04:00
|
|
|
return static_cast<DalamudInjectMethod>(m_config->dalamudInjectMethod());
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-20 16:28:59 -04:00
|
|
|
void Profile::setDalamudInjectMethod(const Profile::DalamudInjectMethod value)
|
2023-07-30 08:49:34 -04:00
|
|
|
{
|
2023-09-20 16:28:59 -04:00
|
|
|
if (static_cast<DalamudInjectMethod>(m_config->dalamudInjectMethod()) != value) {
|
|
|
|
m_config->setDalamudInjectMethod(static_cast<int>(value));
|
2023-08-18 12:59:07 -04:00
|
|
|
m_config->save();
|
2023-09-20 16:28:59 -04:00
|
|
|
Q_EMIT dalamudInjectMethodChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::dalamudInjectDelay() const
|
|
|
|
{
|
|
|
|
return m_config->dalamudInjectDelay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setDalamudInjectDelay(const int value)
|
|
|
|
{
|
|
|
|
if (m_config->dalamudInjectDelay() != value) {
|
|
|
|
m_config->setDalamudInjectDelay(static_cast<int>(value));
|
|
|
|
m_config->save();
|
|
|
|
Q_EMIT dalamudInjectDelayChanged();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Account *Profile::account() const
|
|
|
|
{
|
|
|
|
return m_account;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setAccount(Account *account)
|
|
|
|
{
|
|
|
|
if (account != m_account) {
|
|
|
|
m_account = account;
|
2023-08-18 12:59:07 -04:00
|
|
|
if (account->uuid() != m_config->account()) {
|
|
|
|
m_config->setAccount(account->uuid());
|
|
|
|
m_config->save();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
Q_EMIT accountChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::readGameVersion()
|
|
|
|
{
|
|
|
|
if (gamePath().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
m_gameData = physis_gamedata_initialize((gamePath() + QStringLiteral("/game")).toStdString().c_str());
|
|
|
|
m_bootData = physis_bootdata_initialize((gamePath() + QStringLiteral("/boot")).toStdString().c_str());
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
if (m_bootData != nullptr) {
|
|
|
|
m_bootVersion = physis_bootdata_get_version(m_bootData);
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
if (m_gameData != nullptr) {
|
|
|
|
m_repositories = physis_gamedata_get_repositories(m_gameData);
|
2023-07-30 08:49:34 -04:00
|
|
|
readGameData();
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_EMIT gameInstallChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::accountUuid() const
|
|
|
|
{
|
2023-08-18 12:59:07 -04:00
|
|
|
return m_config->account();
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::expansionVersionText() const
|
|
|
|
{
|
|
|
|
if (!isGameInstalled()) {
|
2023-09-17 08:51:26 -04:00
|
|
|
return i18n("No game installed.");
|
2023-07-30 08:49:34 -04:00
|
|
|
} else {
|
|
|
|
QString expacString;
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
expacString += QStringLiteral("Boot");
|
|
|
|
expacString += QStringLiteral(" (%1)").arg(m_bootVersion);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
for (unsigned int i = 0; i < m_repositories.repositories_count; i++) {
|
|
|
|
QString expansionName = i18n("Unknown Expansion");
|
|
|
|
if (i < static_cast<unsigned int>(m_expansionNames.size())) {
|
|
|
|
expansionName = m_expansionNames[i];
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
expacString += QStringLiteral("\n%1 (%2)").arg(expansionName, m_repositories.repositories[i].version);
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return expacString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::dalamudVersionText() const
|
|
|
|
{
|
|
|
|
QString text;
|
2023-09-17 08:51:26 -04:00
|
|
|
if (m_dalamudVersion.isEmpty()) {
|
|
|
|
text += i18n("Dalamud is not installed.");
|
2023-07-30 08:49:34 -04:00
|
|
|
} else {
|
2023-09-17 08:51:26 -04:00
|
|
|
text += QStringLiteral("Dalamud (%1)").arg(m_dalamudVersion);
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-09-17 08:51:26 -04:00
|
|
|
if (m_dalamudAssetVersion != -1) {
|
|
|
|
text += QStringLiteral("\nAssets (%1)").arg(QString::number(m_dalamudAssetVersion));
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::uuid() const
|
|
|
|
{
|
|
|
|
return m_uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::wineVersionText() const
|
|
|
|
{
|
|
|
|
if (m_launcher.isSteam()) {
|
2023-09-17 08:51:26 -04:00
|
|
|
return i18n("Wine is being managed by Steam.");
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isWineInstalled()) {
|
2023-09-17 08:51:26 -04:00
|
|
|
return i18n("Wine is not installed.");
|
2023-07-30 08:49:34 -04:00
|
|
|
} else {
|
|
|
|
return m_wineVersion;
|
|
|
|
}
|
|
|
|
}
|
2023-08-18 14:52:06 -04:00
|
|
|
|
|
|
|
QString Profile::dalamudChannelName() const
|
|
|
|
{
|
|
|
|
switch (dalamudChannel()) {
|
|
|
|
case DalamudChannel::Stable:
|
|
|
|
return QStringLiteral("stable");
|
|
|
|
case DalamudChannel::Staging:
|
|
|
|
return QStringLiteral("staging");
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
2023-09-17 08:51:26 -04:00
|
|
|
|
|
|
|
[[nodiscard]] bool Profile::isGameInstalled() const
|
|
|
|
{
|
|
|
|
return m_repositories.repositories_count > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool Profile::isWineInstalled() const
|
|
|
|
{
|
|
|
|
return !m_wineVersion.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::bootVersion() const
|
|
|
|
{
|
|
|
|
return m_bootVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::baseGameVersion() const
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_repositories.repositories_count > 1);
|
|
|
|
return m_repositories.repositories[0].version;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::numInstalledExpansions() const
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_repositories.repositories_count > 1);
|
|
|
|
return m_repositories.repositories_count - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::expansionVersion(const int index) const
|
|
|
|
{
|
2023-09-17 09:40:39 -04:00
|
|
|
Q_ASSERT(index <= numInstalledExpansions());
|
2023-09-17 08:51:26 -04:00
|
|
|
return m_repositories.repositories[index + 1].version;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Profile::dalamudAssetVersion() const
|
|
|
|
{
|
|
|
|
return m_dalamudAssetVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setDalamudAssetVersion(int version)
|
|
|
|
{
|
|
|
|
m_dalamudAssetVersion = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::runtimeVersion() const
|
|
|
|
{
|
|
|
|
return m_runtimeVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Profile::dalamudVersion() const
|
|
|
|
{
|
|
|
|
return m_dalamudVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setDalamudVersion(const QString &version)
|
|
|
|
{
|
|
|
|
m_dalamudVersion = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
BootData *Profile::bootData()
|
|
|
|
{
|
|
|
|
return m_bootData;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameData *Profile::gameData()
|
|
|
|
{
|
|
|
|
return m_gameData;
|
|
|
|
}
|
2023-09-17 19:30:22 -04:00
|
|
|
|
|
|
|
bool Profile::loggedIn() const
|
|
|
|
{
|
|
|
|
return m_loggedIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Profile::setLoggedIn(const bool value)
|
|
|
|
{
|
|
|
|
if (m_loggedIn != value) {
|
|
|
|
m_loggedIn = value;
|
|
|
|
Q_EMIT loggedInChanged();
|
|
|
|
}
|
|
|
|
}
|