Manual option for backup master server.

Reimplementation of `7e4be0edd7756220dd8d7fbaaaf3d972db48df5e` from the
old origin.
This commit is contained in:
Cerapter 2018-08-19 08:37:01 +02:00
parent 457a5e39fc
commit feee84588c
5 changed files with 32 additions and 5 deletions

View File

@ -13,13 +13,13 @@
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
{
// Create the QSettings class that points to the config.ini.
configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
net_manager = new NetworkManager(this);
discord = new AttorneyOnline::Discord();
QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)),
SLOT(ms_connect_finished(bool, bool)));
// Create the QSettings class that points to the config.ini.
configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
}
AOApplication::~AOApplication()

View File

@ -145,6 +145,24 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
GameplayForm->setWidget(6, QFormLayout::FieldRole, ShownameCheckbox);
NetDivider = new QFrame(formLayoutWidget);
NetDivider->setFrameShape(QFrame::HLine);
NetDivider->setFrameShadow(QFrame::Sunken);
GameplayForm->setWidget(7, QFormLayout::FieldRole, NetDivider);
MasterServerLabel = new QLabel(formLayoutWidget);
MasterServerLabel->setText("Backup MS:");
MasterServerLabel->setToolTip("After the built-in server lookups fail, the game will try the address given here and use it as a backup masterserver address.");
GameplayForm->setWidget(8, QFormLayout::LabelRole, MasterServerLabel);
QSettings* configini = ao_app->configini;
MasterServerLineEdit = new QLineEdit(formLayoutWidget);
MasterServerLineEdit->setText(configini->value("master", "").value<QString>());
GameplayForm->setWidget(8, QFormLayout::FieldRole, MasterServerLineEdit);
// Here we start the callwords tab.
CallwordsTab = new QWidget();
SettingsTabs->addTab(CallwordsTab, "Callwords");
@ -298,6 +316,7 @@ void AOOptionsDialog::save_pressed()
configini->setValue("log_maximum", LengthSpinbox->value());
configini->setValue("default_username", UsernameLineEdit->text());
configini->setValue("show_custom_shownames", ShownameCheckbox->isChecked());
configini->setValue("master", MasterServerLineEdit->text());
QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");
@ -319,6 +338,7 @@ void AOOptionsDialog::save_pressed()
configini->setValue("blip_rate", BlipRateSpinbox->value());
configini->setValue("blank_blip", BlankBlipsCheckbox->isChecked());
callwordsini->close();
done(0);
}

View File

@ -46,6 +46,9 @@ private:
QLabel *UsernameLabel;
QLabel *ShownameLabel;
QCheckBox *ShownameCheckbox;
QFrame *NetDivider;
QLabel *MasterServerLabel;
QLineEdit *MasterServerLineEdit;
QWidget *CallwordsTab;
QWidget *verticalLayoutWidget;
QVBoxLayout *CallwordsLayout;

View File

@ -19,6 +19,10 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent)
QObject::connect(ms_socket, SIGNAL(readyRead()), this, SLOT(handle_ms_packet()));
QObject::connect(server_socket, SIGNAL(readyRead()), this, SLOT(handle_server_packet()));
QObject::connect(server_socket, SIGNAL(disconnected()), ao_app, SLOT(server_disconnected()));
QString master_config = ao_app->configini->value("master", "").value<QString>();
if (master_config != "")
ms_nosrv_hostname = master_config;
}
NetworkManager::~NetworkManager()

View File

@ -38,9 +38,9 @@ public:
const QString ms_srv_hostname = "_aoms._tcp.aceattorneyonline.com";
#ifdef LOCAL_MS
const QString ms_nosrv_hostname = "localhost";
QString ms_nosrv_hostname = "localhost";
#else
const QString ms_nosrv_hostname = "master.aceattorneyonline.com";
QString ms_nosrv_hostname = "master.aceattorneyonline.com";
#endif
const int ms_port = 27016;