diff --git a/aoapplication.cpp b/aoapplication.cpp index 43af15f..65dcd54 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -45,7 +45,8 @@ void AOApplication::construct_lobby() int y = (screenGeometry.height()-w_lobby->height()) / 2; w_lobby->move(x, y); - discord->state_lobby(); + if (is_discord_enabled()) + discord->state_lobby(); w_lobby->show(); } diff --git a/aoapplication.h b/aoapplication.h index d386811..6e0ce8e 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -143,8 +143,12 @@ public: //Returns the value of default_blip in config.ini int get_default_blip(); - //Returns the value of the maximum amount of lines the IC chatlog - //may contain, from config.ini. + // Returns the value of whether Discord should be enabled on startup + // from the config.ini. + bool is_discord_enabled(); + + // Returns the value of the maximum amount of lines the IC chatlog + // may contain, from config.ini. int get_max_log_size(); // Returns whether the log should go upwards (new behaviour) diff --git a/aooptionsdialog.cpp b/aooptionsdialog.cpp index 60d8a96..3a4a34a 100644 --- a/aooptionsdialog.cpp +++ b/aooptionsdialog.cpp @@ -163,6 +163,17 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi GameplayForm->setWidget(8, QFormLayout::FieldRole, MasterServerLineEdit); + DiscordLabel = new QLabel(formLayoutWidget); + DiscordLabel->setText("Discord:"); + DiscordLabel->setToolTip("If true, allows Discord's Rich Presence to read data about your game. These are: what server you are in, what character are you playing, and how long have you been playing for."); + + GameplayForm->setWidget(9, QFormLayout::LabelRole, DiscordLabel); + + DiscordCheckBox = new QCheckBox(formLayoutWidget); + DiscordCheckBox->setChecked(ao_app->is_discord_enabled()); + + GameplayForm->setWidget(9, QFormLayout::FieldRole, DiscordCheckBox); + // Here we start the callwords tab. CallwordsTab = new QWidget(); SettingsTabs->addTab(CallwordsTab, "Callwords"); @@ -317,6 +328,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("default_username", UsernameLineEdit->text()); configini->setValue("show_custom_shownames", ShownameCheckbox->isChecked()); configini->setValue("master", MasterServerLineEdit->text()); + configini->setValue("discord", DiscordCheckBox->isChecked()); QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); diff --git a/aooptionsdialog.h b/aooptionsdialog.h index cc345ca..f43e7b7 100644 --- a/aooptionsdialog.h +++ b/aooptionsdialog.h @@ -49,6 +49,8 @@ private: QFrame *NetDivider; QLabel *MasterServerLabel; QLineEdit *MasterServerLineEdit; + QLabel *DiscordLabel; + QCheckBox *DiscordCheckBox; QWidget *CallwordsTab; QWidget *verticalLayoutWidget; QVBoxLayout *CallwordsLayout; diff --git a/courtroom.cpp b/courtroom.cpp index 5800f58..f8c7c8a 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -731,13 +731,16 @@ void Courtroom::enter_courtroom(int p_cid) if (m_cid == -1) { - ao_app->discord->state_spectate(); + if (ao_app->is_discord_enabled()) + ao_app->discord->state_spectate(); f_char = ""; } else { f_char = ao_app->get_char_name(char_list.at(m_cid).name); - ao_app->discord->state_character(f_char.toStdString()); + + if (ao_app->is_discord_enabled()) + ao_app->discord->state_character(f_char.toStdString()); } current_char = f_char;