diff --git a/lang/en.json b/lang/en.json index 312978928..d2770e60e 100644 --- a/lang/en.json +++ b/lang/en.json @@ -78,6 +78,8 @@ "optimizeDatabaseDesc": "Run maintenance tasks to increase database performance and reduce size", "showDeveloperTab": "Show Developer Tab", "showDeveloperTabDesc": "Show the 'Developer' tab. This is most likely only useful for developers and curators.", + "registerProtocol": "Register As Protocol Handler", + "registerProtocolDesc": "Registers the launcher to respond to 'flashpoint://' protocol requests.", "server": "Server", "serverDesc": "Which Server to run when playing games.", "curateServer": "Curate Server", diff --git a/src/main/Main.ts b/src/main/Main.ts index bf472aff3..5abad7e85 100644 --- a/src/main/Main.ts +++ b/src/main/Main.ts @@ -122,6 +122,9 @@ export function main(init: Init): void { ipcMain.handle(CustomIPC.SHOW_SAVE_DIALOG, async (event, opts) => { return dialog.showSaveDialog(opts); }); + ipcMain.handle(CustomIPC.REGISTER_PROTOCOL, async (event, register) => { + return setProtocolRegistrationState(register); + }); // Add Socket event listener(s) state.socket.register(BackOut.QUIT, () => { diff --git a/src/renderer/components/pages/ConfigPage.tsx b/src/renderer/components/pages/ConfigPage.tsx index 39e0df581..9e1a1970b 100644 --- a/src/renderer/components/pages/ConfigPage.tsx +++ b/src/renderer/components/pages/ConfigPage.tsx @@ -2,6 +2,8 @@ import { WithPreferencesProps } from '@renderer/containers/withPreferences'; import { WithTagCategoriesProps } from '@renderer/containers/withTagCategories'; import { BackIn } from '@shared/back/types'; import { AppExtConfigData } from '@shared/config/interfaces'; +import { CustomIPC } from '@shared/interfaces'; +import { ipcRenderer } from 'electron'; import { ExtConfigurationProp, ExtensionContribution, IExtensionDescription, ILogoSet } from '@shared/extensions/interfaces'; import { autoCode, LangContainer, LangFile } from '@shared/lang'; import { memoizeOne } from '@shared/memoize'; @@ -336,6 +338,12 @@ export class ConfigPage extends React.Component + {/* Register As Protocol Handler */} + {/* Server */} { + updatePreferencesData({ registerProtocol: isChecked }); + ipcRenderer.invoke(CustomIPC.REGISTER_PROTOCOL, isChecked) + .then((success) => { + if (!success) { + const regVerb = isChecked ? 'add' : 'remove'; + alert('Failed to ' + regVerb + ' protocol registration'); + } + }); + }; + onCurrentThemeChange = (value: string): void => { const selectedTheme = this.props.themeList.find(t => t.id === value); if (selectedTheme) { diff --git a/src/shared/interfaces.ts b/src/shared/interfaces.ts index f07530413..763b25887 100644 --- a/src/shared/interfaces.ts +++ b/src/shared/interfaces.ts @@ -153,7 +153,8 @@ export enum WindowIPC { export enum CustomIPC { SHOW_MESSAGE_BOX = 'show-message-box', SHOW_SAVE_DIALOG = 'show-save-dialog', - SHOW_OPEN_DIALOG = 'show-open-dialog' + SHOW_OPEN_DIALOG = 'show-open-dialog', + REGISTER_PROTOCOL = 'register-protocol' } /** IPC channels used to relay game manager events from */ diff --git a/src/shared/lang.ts b/src/shared/lang.ts index 1b42131b4..7ccbadcbe 100644 --- a/src/shared/lang.ts +++ b/src/shared/lang.ts @@ -84,6 +84,8 @@ const langTemplate = { 'optimizeDatabaseDesc', 'showDeveloperTab', 'showDeveloperTabDesc', + 'registerProtocol', + 'registerProtocolDesc', 'server', 'serverDesc', 'curateServer',