Move Discord Rich Presence behind a compile-time option

This commit is contained in:
David Hrdlička
2023-02-01 17:17:56 +01:00
parent 4ebbeec488
commit 7490bb12c9
27 changed files with 90 additions and 6 deletions

View File

@@ -52,7 +52,9 @@ extern "C" {
#include <86box/plat.h>
#include <86box/ui.h>
#include <86box/video.h>
#include <86box/discord.h>
#ifdef DISCORD
# include <86box/discord.h>
#endif
#include <86box/gdbstub.h>
}
@@ -196,7 +198,9 @@ main(int argc, char *argv[])
return 0;
}
#ifdef DISCORD
discord_load();
#endif
main_window = new MainWindow();
if (startMaximized) {
@@ -271,12 +275,14 @@ main(int argc, char *argv[])
/* Set the PAUSE mode depending on the renderer. */
// plat_pause(0);
QTimer onesec;
QTimer discordupdate;
QObject::connect(&onesec, &QTimer::timeout, &app, [] {
pc_onesec();
});
onesec.setTimerType(Qt::PreciseTimer);
onesec.start(1000);
#ifdef DISCORD
QTimer discordupdate;
if (discord_loaded) {
QTimer::singleShot(1000, &app, [] {
if (enable_discord) {
@@ -290,6 +296,7 @@ main(int argc, char *argv[])
});
discordupdate.start(1000);
}
#endif
/* Initialize the rendering window, or fullscreen. */
QTimer::singleShot(0, &app, [] {

View File

@@ -39,7 +39,9 @@ extern "C" {
#include <86box/keyboard.h>
#include <86box/plat.h>
#include <86box/ui.h>
#include <86box/discord.h>
#ifdef DISCORD
# include <86box/discord.h>
#endif
#include <86box/device.h>
#include <86box/video.h>
#include <86box/machine.h>
@@ -305,6 +307,10 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionEnable_Discord_integration->setChecked(enable_discord);
ui->actionApply_fullscreen_stretch_mode_when_maximized->setChecked(video_fullscreen_scale_maximized);
#ifndef DISCORD
ui->actionEnable_Discord_integration->setVisible(false);
#endif
#if defined Q_OS_WINDOWS || defined Q_OS_MACOS
/* Make the option visible only if ANGLE is loaded. */
ui->actionHardware_Renderer_OpenGL_ES->setVisible(QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES);
@@ -2292,11 +2298,13 @@ void
MainWindow::on_actionEnable_Discord_integration_triggered(bool checked)
{
enable_discord = checked;
#ifdef DISCORD
if (enable_discord) {
discord_init();
discord_update_activity(dopause);
} else
discord_close();
#endif
}
void

View File

@@ -103,7 +103,9 @@ extern "C" {
#include <86box/rom.h>
#include <86box/config.h>
#include <86box/ui.h>
#include <86box/discord.h>
#ifdef DISCORD
# include <86box/discord.h>
#endif
#include "../cpu/cpu.h"
#include <86box/plat.h>
@@ -377,7 +379,11 @@ plat_pause(int p)
} else {
ui_window_title(oldtitle);
}
#ifdef DISCORD
discord_update_activity(dopause);
#endif
QTimer::singleShot(0, main_window, &MainWindow::updateUiPauseState);
#ifdef Q_OS_WINDOWS