win_discord: configurability
This commit is contained in:
@@ -115,6 +115,9 @@ extern int network_type; /* (C) net provider type */
|
||||
extern int network_card; /* (C) net interface num */
|
||||
extern char network_host[522]; /* (C) host network intf */
|
||||
extern int hdd_format_type; /* (C) hard disk file format */
|
||||
#ifdef USE_DISCORD
|
||||
extern int enable_discord; /* (C) enable Discord integration */
|
||||
#endif
|
||||
|
||||
extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out,
|
||||
how to remove that hack from the ET4000/W32p. */
|
||||
|
||||
11
src/config.c
11
src/config.c
@@ -486,6 +486,10 @@ load_general(void)
|
||||
*/
|
||||
plat_langid = config_get_hex16(cat, "language", 0x0409);
|
||||
#endif
|
||||
|
||||
#if USE_DISCORD
|
||||
enable_discord = !!config_get_int(cat, "enable_discord", 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1387,6 +1391,13 @@ save_general(void)
|
||||
config_set_hex16(cat, "language", plat_langid);
|
||||
#endif
|
||||
|
||||
#if USE_DISCORD
|
||||
if (enable_discord)
|
||||
config_set_int(cat, "enable_discord", enable_discord);
|
||||
else
|
||||
config_delete_var(cat, "enable_discord");
|
||||
#endif
|
||||
|
||||
delete_section_if_empty(cat);
|
||||
}
|
||||
|
||||
|
||||
3
src/pc.c
3
src/pc.c
@@ -132,6 +132,9 @@ int cpu_manufacturer = 0, /* (C) cpu manufacturer */
|
||||
cpu = 3, /* (C) cpu type */
|
||||
enable_external_fpu = 0; /* (C) enable external FPU */
|
||||
int time_sync = 0; /* (C) enable time sync */
|
||||
#ifdef USE_DISCORD
|
||||
int enable_discord = 0; /* (C) enable Discord integration */
|
||||
#endif
|
||||
|
||||
/* Statistics. */
|
||||
extern int
|
||||
|
||||
@@ -120,6 +120,10 @@ BEGIN
|
||||
BEGIN
|
||||
MENUITEM "&Settings...", IDM_CONFIG
|
||||
MENUITEM "&Update status bar icons", IDM_UPDATE_ICONS
|
||||
# ifdef USE_DISCORD
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Enable &Discord integration", IDM_DISCORD
|
||||
# endif
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Take s&creenshot\tCtrl+F11", IDM_ACTION_SCREENSHOT
|
||||
END
|
||||
|
||||
@@ -428,6 +428,7 @@ endif
|
||||
|
||||
ifeq ($(DISCORD), y)
|
||||
OPTS += -DUSE_DISCORD
|
||||
RFLAGS += -DUSE_DISCORD
|
||||
DISCORDOBJ := win_discord.o
|
||||
endif
|
||||
|
||||
|
||||
@@ -434,6 +434,7 @@ endif
|
||||
|
||||
ifeq ($(DISCORD), y)
|
||||
OPTS += -DUSE_DISCORD
|
||||
RFLAGS += -DUSE_DISCORD
|
||||
DISCORDOBJ := win_discord.o
|
||||
endif
|
||||
|
||||
|
||||
@@ -301,6 +301,10 @@
|
||||
#define IDM_VID_GRAY_GREEN 40083
|
||||
#define IDM_VID_GRAY_WHITE 40084
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
#define IDM_DISCORD 40090
|
||||
#endif
|
||||
|
||||
#define IDM_LOG_BREAKPOINT 51201
|
||||
#define IDM_DUMP_VRAM 51202 // should be an Action
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#define PATH_DISCORD_DLL "discord_game_sdk.dll"
|
||||
|
||||
int discord_loaded = 0;
|
||||
|
||||
static void *discord_handle = NULL;
|
||||
static struct IDiscordCore *discord_core = NULL;
|
||||
static struct IDiscordActivityManager *discord_activities = NULL;
|
||||
@@ -114,25 +116,36 @@ discord_update_activity(int paused)
|
||||
discord_activities->update_activity(discord_activities, &activity, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
discord_init()
|
||||
int
|
||||
discord_load()
|
||||
{
|
||||
enum EDiscordResult result;
|
||||
struct DiscordCreateParams params;
|
||||
|
||||
discord_log("win_discord: init\n");
|
||||
if (discord_handle != NULL)
|
||||
return(1);
|
||||
|
||||
// Try to load the DLL
|
||||
if (discord_handle == NULL)
|
||||
discord_handle = dynld_module(PATH_DISCORD_DLL, discord_imports);
|
||||
|
||||
if (discord_handle == NULL)
|
||||
{
|
||||
discord_log("win_discord: couldn't load " PATH_DISCORD_DLL "\n");
|
||||
discord_close();
|
||||
return;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
discord_loaded = 1;
|
||||
return(1);
|
||||
}
|
||||
|
||||
void
|
||||
discord_init()
|
||||
{
|
||||
enum EDiscordResult result;
|
||||
struct DiscordCreateParams params;
|
||||
|
||||
if(discord_handle == NULL)
|
||||
return;
|
||||
|
||||
DiscordCreateParamsSetDefault(¶ms);
|
||||
params.client_id = 651478134352248832;
|
||||
params.flags = DiscordCreateFlags_NoRequireDiscord;
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#ifndef WIN_DISCORD_H
|
||||
# define WIN_DISCORD_H
|
||||
|
||||
extern int discord_loaded;
|
||||
|
||||
extern int discord_load();
|
||||
extern void discord_init();
|
||||
extern void discord_close();
|
||||
extern void discord_update_activity(int paused);
|
||||
|
||||
@@ -237,6 +237,13 @@ ResetAllMenus(void)
|
||||
CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED);
|
||||
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED);
|
||||
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED);
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
if (discord_loaded)
|
||||
CheckMenuItem(menuMain, IDM_DISCORD, enable_discord ? MF_CHECKED : MF_UNCHECKED);
|
||||
else
|
||||
EnableMenuItem(menuMain, IDM_DISCORD, MF_DISABLED);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -530,6 +537,19 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
config_save();
|
||||
break;
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
case IDM_DISCORD:
|
||||
if (! discord_loaded) break;
|
||||
enable_discord ^= 1;
|
||||
CheckMenuItem(hmenu, IDM_DISCORD, enable_discord ? MF_CHECKED : MF_UNCHECKED);
|
||||
if(enable_discord) {
|
||||
discord_init();
|
||||
discord_update_activity(dopause);
|
||||
} else
|
||||
discord_close();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LOG_TOGGLES
|
||||
# ifdef ENABLE_BUSLOGIC_LOG
|
||||
case IDM_LOG_BUSLOGIC:
|
||||
@@ -845,6 +865,18 @@ ui_init(int nCmdShow)
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
if(! discord_load()) {
|
||||
enable_discord = 0;
|
||||
} else if (enable_discord) {
|
||||
/* Initialize the Discord API */
|
||||
discord_init();
|
||||
|
||||
/* Update Discord status */
|
||||
discord_update_activity(dopause);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create our main window's class and register it. */
|
||||
wincl.hInstance = hinstance;
|
||||
wincl.lpszClassName = CLASS_NAME;
|
||||
@@ -995,14 +1027,6 @@ ui_init(int nCmdShow)
|
||||
if (source_hwnd)
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDHWND, (WPARAM) unique_id, (LPARAM) hwndMain);
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
/* Initialize the Discord API */
|
||||
discord_init();
|
||||
|
||||
/* Update Discord status */
|
||||
discord_update_activity(dopause);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Everything has been configured, and all seems to work,
|
||||
* so now it is time to start the main thread to do some
|
||||
@@ -1042,6 +1066,7 @@ ui_init(int nCmdShow)
|
||||
|
||||
#ifdef USE_DISCORD
|
||||
/* Run Discord API callbacks */
|
||||
if (enable_discord)
|
||||
discord_run_callbacks();
|
||||
#endif
|
||||
}
|
||||
@@ -1124,6 +1149,7 @@ plat_pause(int p)
|
||||
|
||||
#if USE_DISCORD
|
||||
/* Update Discord status */
|
||||
if(enable_discord)
|
||||
discord_update_activity(dopause);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user