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,6 +45,7 @@ void AOApplication::construct_lobby()
int y = (screenGeometry.height()-w_lobby->height()) / 2;
w_lobby->move(x, y);
if (is_discord_enabled())
discord->state_lobby();
w_lobby->show();

View File

@ -143,6 +143,10 @@ public:
//Returns the value of default_blip in config.ini
int get_default_blip();
// 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();

View File

@ -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");

View File

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

View File

@ -731,12 +731,15 @@ void Courtroom::enter_courtroom(int p_cid)
if (m_cid == -1)
{
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);
if (ao_app->is_discord_enabled())
ao_app->discord->state_character(f_char.toStdString());
}