summaryrefslogtreecommitdiff
path: root/frontend/src/plugin-loader.tsx
diff options
context:
space:
mode:
authorAAGaming <aagaming@riseup.net>2024-10-04 23:59:53 -0400
committerAAGaming <aagaming@riseup.net>2024-10-11 15:05:15 -0400
commit7b32df09487383897927356547f1ba5a73e8cc94 (patch)
tree18932621c4d2ac794e5fd1b5cb6968c4554b66e0 /frontend/src/plugin-loader.tsx
parent306b0ff8d6206a912478ed1e3d3dbf82b8a85c41 (diff)
downloaddecky-loader-7b32df09487383897927356547f1ba5a73e8cc94.tar.gz
decky-loader-7b32df09487383897927356547f1ba5a73e8cc94.zip
Add routerhook for desktop UI and a basic sidebar menu for Decky in desktop UI
Diffstat (limited to 'frontend/src/plugin-loader.tsx')
-rw-r--r--frontend/src/plugin-loader.tsx40
1 files changed, 35 insertions, 5 deletions
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx
index cb1bb270..442f077e 100644
--- a/frontend/src/plugin-loader.tsx
+++ b/frontend/src/plugin-loader.tsx
@@ -1,4 +1,4 @@
-import { ToastNotification } from '@decky/api';
+import type { ToastNotification } from '@decky/api';
import {
ModalRoot,
Navigation,
@@ -13,6 +13,7 @@ import {
import { FC, lazy } from 'react';
import { FaDownload, FaExclamationCircle, FaPlug } from 'react-icons/fa';
+import DeckyDesktopUI from './components/DeckyDesktopUI';
import DeckyIcon from './components/DeckyIcon';
import { DeckyState, DeckyStateContextProvider, UserInfo, useDeckyState } from './components/DeckyState';
import { File, FileSelectionType } from './components/modals/filepicker';
@@ -24,13 +25,14 @@ import NotificationBadge from './components/NotificationBadge';
import PluginView from './components/PluginView';
import { useQuickAccessVisible } from './components/QuickAccessVisibleState';
import WithSuspense from './components/WithSuspense';
+import { UIMode } from './enums';
import ErrorBoundaryHook from './errorboundary-hook';
import { FrozenPluginService } from './frozen-plugins-service';
import { HiddenPluginsService } from './hidden-plugins-service';
import Logger from './logger';
import { NotificationService } from './notification-service';
import { InstallType, Plugin, PluginLoadType } from './plugin';
-import RouterHook, { UIMode } from './router-hook';
+import RouterHook from './router-hook';
import { deinitSteamFixes, initSteamFixes } from './steamfixes';
import { checkForPluginUpdates } from './store';
import TabsHook from './tabs-hook';
@@ -160,6 +162,21 @@ class PluginLoader extends Logger {
);
});
+ // needs the 1s wait or the entire app becomes drag target lol
+ sleep(1000).then(() =>
+ this.routerHook.addGlobalComponent(
+ 'DeckyDesktopUI',
+ () => {
+ return (
+ <DeckyStateContextProvider deckyState={this.deckyState}>
+ <DeckyDesktopUI />
+ </DeckyStateContextProvider>
+ );
+ },
+ UIMode.Desktop,
+ ),
+ );
+
initSteamFixes();
initFilepickerPatches();
@@ -362,6 +379,7 @@ class PluginLoader extends Logger {
public deinit() {
this.routerHook.removeRoute('/decky/store');
this.routerHook.removeRoute('/decky/settings');
+ this.routerHook.removeGlobalComponent('DeckyDesktopUI', UIMode.Desktop);
deinitSteamFixes();
deinitFilepickerPatches();
this.routerHook.deinit();
@@ -627,8 +645,8 @@ class PluginLoader extends Logger {
// Things will break *very* badly if plugin code touches this outside of @decky/api, so lets make that clear.
window.__DECKY_SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_deckyLoaderAPIInit = {
connect: (version: number, pluginName: string) => {
- if (version < 1 || version > 2) {
- console.warn(`Plugin ${pluginName} requested unsupported api version ${version}.`);
+ if (version < 1 || version > 3) {
+ console.warn(`Plugin ${pluginName} requested unsupported API version ${version}.`);
}
const eventListeners: listenerMap = new Map();
@@ -671,12 +689,20 @@ class PluginLoader extends Logger {
_version: 1,
} as any;
+ // adds useQuickAccessVisible
if (version >= 2) {
backendAPI._version = 2;
backendAPI.useQuickAccessVisible = useQuickAccessVisible;
}
- this.debug(`${pluginName} connected to loader API.`);
+ // adds uiMode param to route patching and global component functions. no functional changes, but we should warn anyway.
+ if (version >= 3) {
+ backendAPI._version = 3;
+ }
+
+ this.debug(
+ `${pluginName} connected to loader API version ${backendAPI._version} (requested version ${version}).`,
+ );
return backendAPI;
},
};
@@ -733,6 +759,10 @@ class PluginLoader extends Logger {
return pluginAPI;
}
+
+ public setDesktopMenuOpen(open: boolean) {
+ this.deckyState.setDesktopMenuOpen(open);
+ }
}
export default PluginLoader;