Ability to toggle Discord RPC.

Reimplementation of `bed0b55e70f13adf772584fc0d31ebfe59597115` from old
origin.
This commit is contained in:
Cerapter 2018-08-19 09:17:48 +02:00
parent ed68084e08
commit 95b8bd72d3
5 changed files with 27 additions and 5 deletions

View File

@ -45,7 +45,8 @@ void AOApplication::construct_lobby()
int y = (screenGeometry.height()-w_lobby->height()) / 2; int y = (screenGeometry.height()-w_lobby->height()) / 2;
w_lobby->move(x, y); w_lobby->move(x, y);
discord->state_lobby(); if (is_discord_enabled())
discord->state_lobby();
w_lobby->show(); w_lobby->show();
} }

View File

@ -143,8 +143,12 @@ public:
//Returns the value of default_blip in config.ini //Returns the value of default_blip in config.ini
int get_default_blip(); int get_default_blip();
//Returns the value of the maximum amount of lines the IC chatlog // Returns the value of whether Discord should be enabled on startup
//may contain, from config.ini. // 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(); int get_max_log_size();
// Returns whether the log should go upwards (new behaviour) // Returns whether the log should go upwards (new behaviour)

View File

@ -163,6 +163,17 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
GameplayForm->setWidget(8, QFormLayout::FieldRole, MasterServerLineEdit); 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. // Here we start the callwords tab.
CallwordsTab = new QWidget(); CallwordsTab = new QWidget();
SettingsTabs->addTab(CallwordsTab, "Callwords"); SettingsTabs->addTab(CallwordsTab, "Callwords");
@ -317,6 +328,7 @@ void AOOptionsDialog::save_pressed()
configini->setValue("default_username", UsernameLineEdit->text()); configini->setValue("default_username", UsernameLineEdit->text());
configini->setValue("show_custom_shownames", ShownameCheckbox->isChecked()); configini->setValue("show_custom_shownames", ShownameCheckbox->isChecked());
configini->setValue("master", MasterServerLineEdit->text()); configini->setValue("master", MasterServerLineEdit->text());
configini->setValue("discord", DiscordCheckBox->isChecked());
QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");

View File

@ -49,6 +49,8 @@ private:
QFrame *NetDivider; QFrame *NetDivider;
QLabel *MasterServerLabel; QLabel *MasterServerLabel;
QLineEdit *MasterServerLineEdit; QLineEdit *MasterServerLineEdit;
QLabel *DiscordLabel;
QCheckBox *DiscordCheckBox;
QWidget *CallwordsTab; QWidget *CallwordsTab;
QWidget *verticalLayoutWidget; QWidget *verticalLayoutWidget;
QVBoxLayout *CallwordsLayout; QVBoxLayout *CallwordsLayout;

View File

@ -731,13 +731,16 @@ void Courtroom::enter_courtroom(int p_cid)
if (m_cid == -1) if (m_cid == -1)
{ {
ao_app->discord->state_spectate(); if (ao_app->is_discord_enabled())
ao_app->discord->state_spectate();
f_char = ""; f_char = "";
} }
else else
{ {
f_char = ao_app->get_char_name(char_list.at(m_cid).name); 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; current_char = f_char;