mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 22:41:25 +12:00
Discord: add some stuff
This commit is contained in:
parent
39e3fb4638
commit
9dea602496
5 changed files with 106 additions and 21 deletions
|
@ -99,7 +99,8 @@
|
|||
"configs": "Only useful to developers.\nIf unsure, don't use this option.",
|
||||
"stylesheets": "Changes the overall look of RPCS3.\nChoose a stylesheet and click Apply to change between styles.",
|
||||
"show_welcome": "Shows the initial welcome screen upon starting RPCS3.",
|
||||
"useRichPresence": "Enables use of Discord Rich Presence to show what game you are playing on Discord.\nRequires a restart of RPCS3 to apply.",
|
||||
"useRichPresence": "Enables use of Discord Rich Presence to show what game you are playing on Discord.\nRequires a restart of RPCS3 to completely close the connection.",
|
||||
"discordState": "Tell your friends what you are doing.",
|
||||
"custom_colors": "Prioritize custom user interface colors over properties set in stylesheet."
|
||||
},
|
||||
"input": {
|
||||
|
|
|
@ -198,6 +198,7 @@ namespace gui
|
|||
const gui_save m_showDebugTab = gui_save(meta, "showDebugTab", false);
|
||||
const gui_save m_enableUIColors = gui_save(meta, "enableUIColors", false);
|
||||
const gui_save m_richPresence = gui_save(meta, "useRichPresence", true);
|
||||
const gui_save m_discordState = gui_save(meta, "discordState", "");
|
||||
|
||||
const gui_save gs_disableMouse = gui_save(gs_frame, "disableMouse", false);
|
||||
const gui_save gs_resize = gui_save(gs_frame, "resize", false);
|
||||
|
|
|
@ -287,7 +287,6 @@ void main_window::Boot(const std::string& path, bool direct, bool add_only)
|
|||
discordPresence.largeImageKey = "rpcs3_logo";
|
||||
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator.";
|
||||
discordPresence.startTimestamp = time(0);
|
||||
discordPresence.instance = 0;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
#endif
|
||||
|
@ -837,9 +836,13 @@ void main_window::OnEmuStop()
|
|||
// Discord Rich Presence Integration
|
||||
if (guiSettings->GetValue(gui::m_richPresence).toBool())
|
||||
{
|
||||
QString discord_state = guiSettings->GetValue(gui::m_discordState).toString();
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.details = "Idle";
|
||||
discordPresence.state = sstr(discord_state).c_str();
|
||||
discordPresence.largeImageKey = "rpcs3_logo";
|
||||
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator.";
|
||||
discordPresence.startTimestamp = time(0);
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
#include <unordered_set>
|
||||
#include <thread>
|
||||
|
||||
#ifdef WITH_DISCORD_RPC
|
||||
#include "discord_rpc.h"
|
||||
#include "discord_register.h"
|
||||
#endif
|
||||
|
||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||
inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); }
|
||||
|
||||
|
@ -99,6 +104,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
setWindowTitle(tr("Settings"));
|
||||
}
|
||||
|
||||
// Discord variables
|
||||
bool use_discord = xgui_settings->GetValue(gui::m_richPresence).toBool();
|
||||
QString discord_state = xgui_settings->GetValue(gui::m_discordState).toString();
|
||||
|
||||
// Various connects
|
||||
connect(ui->okButton, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
|
@ -115,6 +124,32 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
xemu_settings->SaveSelectedLibraries(selected_ls);
|
||||
xemu_settings->SaveSettings();
|
||||
accept();
|
||||
|
||||
#ifdef WITH_DISCORD_RPC
|
||||
bool use_discord_new = xgui_settings->GetValue(gui::m_richPresence).toBool();
|
||||
QString discord_state_new = xgui_settings->GetValue(gui::m_discordState).toString();
|
||||
|
||||
if (use_discord != use_discord_new || discord_state != discord_state_new)
|
||||
{
|
||||
if (use_discord_new)
|
||||
{
|
||||
DiscordEventHandlers handlers = {};
|
||||
Discord_Initialize("424004941485572097", &handlers, 1, NULL);
|
||||
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.details = "Idle";
|
||||
discordPresence.state = sstr(discord_state_new).c_str();
|
||||
discordPresence.largeImageKey = "rpcs3_logo";
|
||||
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator.";
|
||||
discordPresence.startTimestamp = time(0);
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
else
|
||||
{
|
||||
Discord_ClearPresence();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
});
|
||||
|
||||
connect(ui->cancelButton, &QAbstractButton::clicked, this, &QWidget::close);
|
||||
|
@ -798,13 +833,6 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
ui->gs_height->setValue(std::min(ui->gs_height->value(), QApplication::desktop()->screenGeometry().height()));
|
||||
xgui_settings->SetValue(gui::gs_height, ui->gs_height->value());
|
||||
});
|
||||
|
||||
ui->useRichPresence->setChecked(xgui_settings->GetValue(gui::m_richPresence).toBool());
|
||||
|
||||
connect(ui->useRichPresence, &QCheckBox::clicked, [=](bool val)
|
||||
{
|
||||
xgui_settings->SetValue(gui::m_richPresence, val);
|
||||
});
|
||||
}
|
||||
|
||||
// _____ _ _ _ _______ _
|
||||
|
@ -827,8 +855,28 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
|
||||
SubscribeTooltip(ui->useRichPresence, json_gui["useRichPresence"].toString());
|
||||
|
||||
SubscribeTooltip(ui->discordState, json_gui["discordState"].toString());
|
||||
|
||||
if (!game)
|
||||
{
|
||||
// Discord:
|
||||
ui->useRichPresence->setChecked(use_discord);
|
||||
ui->label_discordState->setEnabled(use_discord);
|
||||
ui->discordState->setEnabled(use_discord);
|
||||
ui->discordState->setText(discord_state);
|
||||
|
||||
connect(ui->useRichPresence, &QCheckBox::clicked, [this](bool checked)
|
||||
{
|
||||
ui->discordState->setEnabled(checked);
|
||||
ui->label_discordState->setEnabled(checked);
|
||||
xgui_settings->SetValue(gui::m_richPresence, checked);
|
||||
});
|
||||
|
||||
connect(ui->discordState, &QLineEdit::editingFinished, [this]()
|
||||
{
|
||||
xgui_settings->SetValue(gui::m_discordState, ui->discordState->text());
|
||||
});
|
||||
|
||||
// colorize preview icons
|
||||
auto addColoredIcon = [&](QPushButton *button, const QColor& color, const QIcon& icon = QIcon(), const QColor& iconColor = QColor())
|
||||
{
|
||||
|
@ -890,7 +938,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
}
|
||||
};
|
||||
|
||||
connect(ui->okButton, &QAbstractButton::clicked, [=]() { ApplyGuiOptions(); });
|
||||
connect(ui->okButton, &QAbstractButton::clicked, [=]()
|
||||
{
|
||||
ApplyGuiOptions();
|
||||
});
|
||||
|
||||
connect(ui->pb_reset_default, &QAbstractButton::clicked, [=]
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>6</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="coreTab">
|
||||
<attribute name="title">
|
||||
|
@ -1556,7 +1556,7 @@
|
|||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_43">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,1,1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
|
@ -1728,13 +1728,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useRichPresence">
|
||||
<property name="text">
|
||||
<string>Use Discord Rich Presence</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_17">
|
||||
<property name="orientation">
|
||||
|
@ -1745,8 +1738,8 @@
|
|||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>13</height>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -1754,6 +1747,42 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_discord">
|
||||
<property name="title">
|
||||
<string>Discord</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_68">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useRichPresence">
|
||||
<property name="text">
|
||||
<string>Use Discord Rich Presence</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_discordState">
|
||||
<property name="text">
|
||||
<string>Discord Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="discordState">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>128</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue