mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 03:37:47 +00:00
Add support for specifying a custom lobby/GM server
This commit is contained in:
parent
69051696e1
commit
4214b769df
8 changed files with 89 additions and 8 deletions
|
@ -54,5 +54,11 @@ SPDX-License-Identifier: CC0-1.0
|
||||||
<entry key="EnableRenderDocCapture" type="bool">
|
<entry key="EnableRenderDocCapture" type="bool">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="CustomGameServer" type="String">
|
||||||
|
<default></default>
|
||||||
|
</entry>
|
||||||
|
<entry name="CustomGameServerPort" type="int">
|
||||||
|
<default>7000</default>
|
||||||
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
</kcfg>
|
</kcfg>
|
||||||
|
|
|
@ -49,7 +49,8 @@ struct LoginAuth {
|
||||||
int maxExpansion = 1;
|
int maxExpansion = 1;
|
||||||
|
|
||||||
// if empty, don't set on the client
|
// if empty, don't set on the client
|
||||||
QString lobbyhost, frontierHost;
|
QString lobbyHost, frontierHost;
|
||||||
|
int lobbyHostPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LauncherCore : public QObject
|
class LauncherCore : public QObject
|
||||||
|
|
|
@ -26,6 +26,8 @@ class LauncherSettings : public QObject
|
||||||
Q_PROPERTY(bool argumentsEncrypted READ argumentsEncrypted WRITE setArgumentsEncrypted NOTIFY encryptedArgumentsChanged)
|
Q_PROPERTY(bool argumentsEncrypted READ argumentsEncrypted WRITE setArgumentsEncrypted NOTIFY encryptedArgumentsChanged)
|
||||||
Q_PROPERTY(bool enableRenderDocCapture READ enableRenderDocCapture WRITE setEnableRenderDocCapture NOTIFY enableRenderDocCaptureChanged)
|
Q_PROPERTY(bool enableRenderDocCapture READ enableRenderDocCapture WRITE setEnableRenderDocCapture NOTIFY enableRenderDocCaptureChanged)
|
||||||
Q_PROPERTY(bool enableSync READ enableSync WRITE setEnableSync NOTIFY enableSyncChanged)
|
Q_PROPERTY(bool enableSync READ enableSync WRITE setEnableSync NOTIFY enableSyncChanged)
|
||||||
|
Q_PROPERTY(QString customGameServer READ customGameServer WRITE setCustomGameServer NOTIFY customGameServerChanged)
|
||||||
|
Q_PROPERTY(int customGameServerPort READ customGameServerPort WRITE setCustomGameServerPort NOTIFY customGameServerPortChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LauncherSettings(QObject *parent = nullptr);
|
explicit LauncherSettings(QObject *parent = nullptr);
|
||||||
|
@ -74,6 +76,12 @@ public:
|
||||||
[[nodiscard]] bool enableSync() const;
|
[[nodiscard]] bool enableSync() const;
|
||||||
void setEnableSync(bool enabled);
|
void setEnableSync(bool enabled);
|
||||||
|
|
||||||
|
[[nodiscard]] QString customGameServer() const;
|
||||||
|
void setCustomGameServer(const QString &value);
|
||||||
|
|
||||||
|
[[nodiscard]] int customGameServerPort() const;
|
||||||
|
void setCustomGameServerPort(int port);
|
||||||
|
|
||||||
Config *config();
|
Config *config();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -89,6 +97,8 @@ Q_SIGNALS:
|
||||||
void encryptedArgumentsChanged();
|
void encryptedArgumentsChanged();
|
||||||
void enableRenderDocCaptureChanged();
|
void enableRenderDocCaptureChanged();
|
||||||
void enableSyncChanged();
|
void enableSyncChanged();
|
||||||
|
void customGameServerChanged();
|
||||||
|
void customGameServerPortChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Config *m_config = nullptr;
|
Config *m_config = nullptr;
|
||||||
|
|
|
@ -228,11 +228,11 @@ QString GameRunner::getGameArgs(const Profile &profile, const std::optional<Logi
|
||||||
Utility::createPathIfNeeded(profile.winePrefixPath());
|
Utility::createPathIfNeeded(profile.winePrefixPath());
|
||||||
|
|
||||||
if (auth) {
|
if (auth) {
|
||||||
if (!auth->lobbyhost.isEmpty()) {
|
if (!auth->lobbyHost.isEmpty()) {
|
||||||
gameArgs.push_back({QStringLiteral("DEV.GMServerHost"), auth->frontierHost});
|
gameArgs.push_back({QStringLiteral("DEV.GMServerHost"), auth->frontierHost});
|
||||||
for (int i = 1; i < 9; i++) {
|
for (int i = 1; i < 9; i++) {
|
||||||
gameArgs.push_back({QStringLiteral("DEV.LobbyHost0%1").arg(QString::number(i)), auth->lobbyhost});
|
gameArgs.push_back({QStringLiteral("DEV.LobbyHost0%1").arg(QString::number(i)), auth->lobbyHost});
|
||||||
gameArgs.push_back({QStringLiteral("DEV.LobbyPort0%1").arg(QString::number(i)), QString::number(54994)});
|
gameArgs.push_back({QStringLiteral("DEV.LobbyPort0%1").arg(QString::number(i)), QString::number(auth->lobbyHostPort)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,34 @@ void LauncherSettings::setEnableSync(const bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LauncherSettings::customGameServer() const
|
||||||
|
{
|
||||||
|
return m_config->customGameServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LauncherSettings::setCustomGameServer(const QString &value)
|
||||||
|
{
|
||||||
|
if (m_config->customGameServer() != value) {
|
||||||
|
m_config->setCustomGameServer(value);
|
||||||
|
m_config->save();
|
||||||
|
Q_EMIT customGameServerChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int LauncherSettings::customGameServerPort() const
|
||||||
|
{
|
||||||
|
return m_config->customGameServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LauncherSettings::setCustomGameServerPort(const int port)
|
||||||
|
{
|
||||||
|
if (m_config->customGameServerPort() != port) {
|
||||||
|
m_config->setCustomGameServerPort(port);
|
||||||
|
m_config->save();
|
||||||
|
Q_EMIT customGameServerPortChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Config *LauncherSettings::config()
|
Config *LauncherSettings::config()
|
||||||
{
|
{
|
||||||
return m_config;
|
return m_config;
|
||||||
|
|
|
@ -40,8 +40,9 @@ QCoro::Task<std::optional<LoginAuth>> SapphireLogin::login(const QString &lobbyU
|
||||||
if (!document.isEmpty()) {
|
if (!document.isEmpty()) {
|
||||||
LoginAuth auth;
|
LoginAuth auth;
|
||||||
auth.SID = document["sId"_L1].toString();
|
auth.SID = document["sId"_L1].toString();
|
||||||
auth.lobbyhost = document["lobbyHost"_L1].toString();
|
auth.lobbyHost = document["lobbyHost"_L1].toString();
|
||||||
auth.frontierHost = document["frontierHost"_L1].toString();
|
auth.frontierHost = document["frontierHost"_L1].toString();
|
||||||
|
auth.lobbyHostPort = 54994; // TODO: where did this come from?
|
||||||
auth.region = 3;
|
auth.region = 3;
|
||||||
|
|
||||||
co_return auth;
|
co_return auth;
|
||||||
|
@ -67,10 +68,10 @@ void SapphireLogin::registerAccount(const QString &lobbyUrl, const LoginInformat
|
||||||
|
|
||||||
LoginAuth auth;
|
LoginAuth auth;
|
||||||
auth.SID = document["sId"_L1].toString();
|
auth.SID = document["sId"_L1].toString();
|
||||||
auth.lobbyhost = document["lobbyHost"_L1].toString();
|
auth.lobbyHost = document["lobbyHost"_L1].toString();
|
||||||
auth.frontierHost = document["frontierHost"_L1].toString();
|
auth.frontierHost = document["frontierHost"_L1].toString();
|
||||||
auth.region = 3;
|
auth.region = 3;
|
||||||
|
|
||||||
// m_launcher.launchGame(*info.profile, auth);
|
// m_launcher.launchGame(*info.profile, auth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,13 @@ QCoro::Task<std::optional<LoginAuth>> SquareEnixLogin::login(LoginInformation *i
|
||||||
co_return std::nullopt;
|
co_return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject custom game server if set
|
||||||
|
if (!m_launcher.settings()->customGameServer().isEmpty()) {
|
||||||
|
m_auth.frontierHost = m_launcher.settings()->customGameServer();
|
||||||
|
m_auth.lobbyHost = m_launcher.settings()->customGameServer();
|
||||||
|
m_auth.lobbyHostPort = m_launcher.settings()->customGameServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
co_return m_auth;
|
co_return m_auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,5 +180,33 @@ FormCard.FormCardPage {
|
||||||
text: LauncherCore.settings.mainServer
|
text: LauncherCore.settings.mainServer
|
||||||
onTextChanged: LauncherCore.settings.mainServer = text
|
onTextChanged: LauncherCore.settings.mainServer = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {
|
||||||
|
above: mainServerDelegate
|
||||||
|
below: gameServerDelegate
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormTextFieldDelegate {
|
||||||
|
id: gameServerDelegate
|
||||||
|
|
||||||
|
label: i18n("Game Server (leave blank for default)")
|
||||||
|
text: LauncherCore.settings.customGameServer
|
||||||
|
onTextChanged: LauncherCore.settings.customGameServer = text
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {
|
||||||
|
above: gameServerDelegate
|
||||||
|
below: gameServerPortDelegate
|
||||||
|
}
|
||||||
|
|
||||||
|
FormCard.FormSpinBoxDelegate {
|
||||||
|
id: gameServerPortDelegate
|
||||||
|
|
||||||
|
label: i18n("Game Server Port")
|
||||||
|
value: LauncherCore.settings.customGameServerPort
|
||||||
|
onValueChanged: LauncherCore.settings.customGameServerPort = value
|
||||||
|
from: 1
|
||||||
|
to: 999999
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue