mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 11:47:46 +00:00
Move Account::updateConfig to LauncherCore
This is the last LauncherCore dependency inside of Account, and it fits better in LauncherCore anyway.
This commit is contained in:
parent
b7aafea3ea
commit
ba89c7f487
4 changed files with 39 additions and 41 deletions
|
@ -83,9 +83,6 @@ public:
|
|||
[[nodiscard]] QDir getConfigDir() const;
|
||||
[[nodiscard]] Q_INVOKABLE QString getConfigPath() const;
|
||||
|
||||
/// Updates FFXIV.cfg with some recommended options like turning the opening cutscene movie off
|
||||
void updateConfig();
|
||||
|
||||
[[nodiscard]] bool needsPassword() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -164,6 +164,9 @@ private:
|
|||
|
||||
QCoro::Task<> handleGameExit(const Profile *profile);
|
||||
|
||||
/// Updates FFXIV.cfg with some recommended options like turning the opening cutscene movie off
|
||||
void updateConfig(const Account *account);
|
||||
|
||||
SteamAPI *m_steamApi = nullptr;
|
||||
|
||||
bool m_loadingFinished = false;
|
||||
|
|
|
@ -281,43 +281,6 @@ QCoro::Task<QString> Account::getKeychainValue(const QString &key)
|
|||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once CppMemberFunctionMayBeConst
|
||||
// ^ Could be const, but this function shouldn't be considered as such
|
||||
void Account::updateConfig()
|
||||
{
|
||||
const auto configDir = getConfigDir().absoluteFilePath(QStringLiteral("FFXIV.cfg"));
|
||||
|
||||
if (!QFile::exists(configDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qInfo(ASTRA_LOG) << "Updating FFXIV.cfg...";
|
||||
|
||||
const auto configDirStd = configDir.toStdString();
|
||||
|
||||
const auto cfgFileBuffer = physis_read_file(configDirStd.c_str());
|
||||
const auto cfgFile = physis_cfg_parse(cfgFileBuffer);
|
||||
|
||||
// Ensure that the opening cutscene movie never plays, since it's broken in most versions of Wine
|
||||
physis_cfg_set_value(cfgFile, "CutsceneMovieOpening", "1");
|
||||
|
||||
const auto screenshotDir = m_launcher.settings()->screenshotDir();
|
||||
Utility::createPathIfNeeded(screenshotDir);
|
||||
|
||||
const auto screenshotDirWin = Utility::toWindowsPath(screenshotDir);
|
||||
const auto screenshotDirWinStd = screenshotDirWin.toStdString();
|
||||
|
||||
// Set the screenshot path
|
||||
physis_cfg_set_value(cfgFile, "ScreenShotDir", screenshotDirWinStd.c_str());
|
||||
|
||||
const auto buffer = physis_cfg_write(cfgFile);
|
||||
|
||||
QFile file(configDir);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(reinterpret_cast<const char *>(buffer.data), buffer.size);
|
||||
file.close();
|
||||
}
|
||||
|
||||
bool Account::needsPassword() const
|
||||
{
|
||||
return m_needsPassword;
|
||||
|
|
|
@ -440,7 +440,7 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
|
|||
{
|
||||
// Hmm, I don't think we're set up for this yet?
|
||||
if (!info.profile->isBenchmark()) {
|
||||
info.profile->account()->updateConfig();
|
||||
updateConfig(info.profile->account());
|
||||
}
|
||||
|
||||
#ifdef BUILD_SYNC
|
||||
|
@ -595,4 +595,39 @@ QCoro::Task<> LauncherCore::handleGameExit(const Profile *profile)
|
|||
co_return;
|
||||
}
|
||||
|
||||
void LauncherCore::updateConfig(const Account *account)
|
||||
{
|
||||
const auto configDir = account->getConfigDir().absoluteFilePath(QStringLiteral("FFXIV.cfg"));
|
||||
|
||||
if (!QFile::exists(configDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qInfo(ASTRA_LOG) << "Updating FFXIV.cfg...";
|
||||
|
||||
const auto configDirStd = configDir.toStdString();
|
||||
|
||||
const auto cfgFileBuffer = physis_read_file(configDirStd.c_str());
|
||||
const auto cfgFile = physis_cfg_parse(cfgFileBuffer);
|
||||
|
||||
// Ensure that the opening cutscene movie never plays, since it's broken in most versions of Wine
|
||||
physis_cfg_set_value(cfgFile, "CutsceneMovieOpening", "1");
|
||||
|
||||
const auto screenshotDir = settings()->screenshotDir();
|
||||
Utility::createPathIfNeeded(screenshotDir);
|
||||
|
||||
const auto screenshotDirWin = Utility::toWindowsPath(screenshotDir);
|
||||
const auto screenshotDirWinStd = screenshotDirWin.toStdString();
|
||||
|
||||
// Set the screenshot path
|
||||
physis_cfg_set_value(cfgFile, "ScreenShotDir", screenshotDirWinStd.c_str());
|
||||
|
||||
const auto buffer = physis_cfg_write(cfgFile);
|
||||
|
||||
QFile file(configDir);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(reinterpret_cast<const char *>(buffer.data), buffer.size);
|
||||
file.close();
|
||||
}
|
||||
|
||||
#include "moc_launchercore.cpp"
|
Loading…
Add table
Reference in a new issue