Add Rich Presence option

This commit is contained in:
isJuhn 2018-04-22 01:45:30 +02:00 committed by Ani
parent 98b715d8c8
commit f27f7d50c9
6 changed files with 42 additions and 14 deletions

View File

@ -54,6 +54,7 @@
"configs": "Only useful to developers.\nIf unsure, don't use this option.", "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.", "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.", "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.",
"custom_colors": "Prioritize custom user interface colors over properties set in stylesheet." "custom_colors": "Prioritize custom user interface colors over properties set in stylesheet."
}, },
"misc": { "misc": {

View File

@ -94,8 +94,12 @@ void rpcs3_app::Init()
welcome->exec(); welcome->exec();
} }
#ifdef WITH_DISCORD_RPC #ifdef WITH_DISCORD_RPC
DiscordEventHandlers handlers = {}; // Discord Rich Presence Integration
Discord_Initialize("424004941485572097", &handlers, 1, NULL); if (guiSettings->GetValue(gui::m_richPresence).toBool())
{
DiscordEventHandlers handlers = {};
Discord_Initialize("424004941485572097", &handlers, 1, NULL);
}
#endif #endif
} }

View File

@ -157,6 +157,7 @@ namespace gui
const gui_save m_saveNotes = gui_save(meta, "saveNotes", QVariantMap()); const gui_save m_saveNotes = gui_save(meta, "saveNotes", QVariantMap());
const gui_save m_showDebugTab = gui_save(meta, "showDebugTab", false); const gui_save m_showDebugTab = gui_save(meta, "showDebugTab", false);
const gui_save m_enableUIColors = gui_save(meta, "enableUIColors", false); const gui_save m_enableUIColors = gui_save(meta, "enableUIColors", false);
const gui_save m_richPresence = gui_save(meta, "useRichPresence", true);
const gui_save gs_disableMouse = gui_save(gs_frame, "disableMouse", false); const gui_save gs_disableMouse = gui_save(gs_frame, "disableMouse", false);
const gui_save gs_resize = gui_save(gs_frame, "resize", false); const gui_save gs_resize = gui_save(gs_frame, "resize", false);

View File

@ -248,14 +248,17 @@ void main_window::Boot(const std::string& path, bool direct, bool add_only)
AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle()))); AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
#ifdef WITH_DISCORD_RPC #ifdef WITH_DISCORD_RPC
// Discord Rich Presence Integration // Discord Rich Presence Integration
DiscordRichPresence discordPresence = {}; if (guiSettings->GetValue(gui::m_richPresence).toBool())
discordPresence.state = Emu.GetTitleID().c_str(); {
discordPresence.details = Emu.GetTitle().c_str(); DiscordRichPresence discordPresence = {};
discordPresence.largeImageKey = "rpcs3_logo"; discordPresence.state = Emu.GetTitleID().c_str();
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator."; discordPresence.details = Emu.GetTitle().c_str();
discordPresence.startTimestamp = time(0); discordPresence.largeImageKey = "rpcs3_logo";
discordPresence.instance = 0; discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator.";
Discord_UpdatePresence(&discordPresence); discordPresence.startTimestamp = time(0);
discordPresence.instance = 0;
Discord_UpdatePresence(&discordPresence);
}
#endif #endif
} }
else else
@ -775,10 +778,13 @@ void main_window::OnEmuStop()
} }
#ifdef WITH_DISCORD_RPC #ifdef WITH_DISCORD_RPC
// Discord Rich Presence Integration // Discord Rich Presence Integration
DiscordRichPresence discordPresence = {}; if (guiSettings->GetValue(gui::m_richPresence).toBool())
discordPresence.largeImageKey = "rpcs3_logo"; {
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator."; DiscordRichPresence discordPresence = {};
Discord_UpdatePresence(&discordPresence); discordPresence.largeImageKey = "rpcs3_logo";
discordPresence.largeImageText = "RPCS3 is the world's first PlayStation 3 emulator.";
Discord_UpdatePresence(&discordPresence);
}
#endif #endif
} }

View File

@ -706,6 +706,8 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
SubscribeTooltip(ui->cb_custom_colors, json_emu_gui["custom_colors"].toString()); SubscribeTooltip(ui->cb_custom_colors, json_emu_gui["custom_colors"].toString());
SubscribeTooltip(ui->useRichPresence, json_emu_gui["useRichPresence"].toString());
xemu_settings->EnhanceCheckBox(ui->exitOnStop, emu_settings::ExitRPCS3OnFinish); xemu_settings->EnhanceCheckBox(ui->exitOnStop, emu_settings::ExitRPCS3OnFinish);
SubscribeTooltip(ui->exitOnStop, json_emu_misc["exitOnStop"].toString()); SubscribeTooltip(ui->exitOnStop, json_emu_misc["exitOnStop"].toString());
@ -907,6 +909,13 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
xgui_settings->SetValue(gui::gs_height, ui->gs_height->value()); 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);
});
AddConfigs(); AddConfigs();
AddStylesheets(); AddStylesheets();
} }

View File

@ -1287,6 +1287,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="useRichPresence">
<property name="text">
<string>Use Discord Rich Presence</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_13"> <spacer name="verticalSpacer_13">
<property name="orientation"> <property name="orientation">