Skip to content

Commit

Permalink
fix(Router): update Router interface to SteamOS3.4 and add Navigation (
Browse files Browse the repository at this point in the history
  • Loading branch information
beebls committed Dec 12, 2022
1 parent ef6be8c commit f0379e5
Showing 1 changed file with 74 additions and 16 deletions.
90 changes: 74 additions & 16 deletions src/deck-components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,38 @@ export type AppOverview = {
sort_as: string;
};

export interface MenuStore {
OpenSideMenu(sideMenu: SideMenu): void;
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
OpenMainMenu(): void;
}

export interface WindowRouter {
BrowserWindow: Window;
MenuStore: MenuStore;
Navigate(path: string): void;
NavigateToChat(): void;
NavigateToSteamWeb(url: string): void;
NavigateBack(): void;
NavigateToWebRoute(unknown?: any, unknown2?: any): void;
}

export interface WindowStore {
GamepadUIMainWindowInstance?: WindowRouter; // Current
SteamUIWindows: WindowRouter[];
OverlayWindows: WindowRouter[]; // Used by desktop GamepadUI
}

export interface Router {
WindowStore?: WindowStore;
CloseSideMenus(): void;
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
GetQuickAccessTab(): QuickAccessTab;
Navigate(path: string): void;
NavigateBackOrOpenMenu(): void;
NavigateToAppProperties(): void;
NavigateToBugForum(): void;
NavigateToExternalWeb(url: string): void;
NavigateToHelp(): void;
NavigateToInvites(): void;
NavigateToRunningApp(replace?: boolean): void;
NavigateToStorage(): void;
NavigateToStore(): void;
NavigateToStoreApp(appId: number | string): void;
NavigateToStoreFreeToPlay(): void;
NavigateToStoreManual(): void;
NavigateToStoreNewReleases(): void;
NavigateToStoreOnSale(): void;
ToggleSideMenu(sideMenu: SideMenu): void;
CloseSideMenus(): void;
OpenSideMenu(sideMenu: SideMenu): void;
NavigateToChat(): void;
NavigateToLibraryTab(): void;
NavigateToLayoutPreview(e: unknown): void;
OpenPowerMenu(unknown?: any): void;
get RunningApps(): AppOverview[];
get MainRunningApp(): AppOverview | undefined;
Expand All @@ -96,3 +106,51 @@ export const Router = findModuleChild((m: Module) => {
if (m[prop]?.Navigate && m[prop]?.NavigationManager) return m[prop];
}
}) as Router;

export interface Navigation {
Navigate(path: string): void;
NavigateBack(): void;
NavigateToAppProperties(): void;
NavigateToExternalWeb(url: string): void;
NavigateToInvites(): void;
NavigateToChat(): void;
NavigateToLibraryTab(): void;
NavigateToLayoutPreview(e: unknown): void;
NavigateToSteamWeb(url: string): void;
NavigateToWebRoute(unknown?: any, unknown2?: any): void;
OpenSideMenu(sideMenu: SideMenu): void;
OpenQuickAccessMenu(quickAccessTab?: QuickAccessTab): void;
OpenMainMenu(): void;
OpenPowerMenu(unknown?: any): void;
CloseSideMenus(): void;
}

export const Navigation = {
Navigate: Router.Navigate.bind(Router),
NavigateBack: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateBack.bind(
Router.WindowStore.GamepadUIMainWindowInstance,
),
NavigateToAppProperties: Router.NavigateToAppProperties.bind(Router),
NavigateToExternalWeb: Router.NavigateToExternalWeb.bind(Router),
NavigateToInvites: Router.NavigateToInvites.bind(Router),
NavigateToChat: Router.NavigateToChat.bind(Router),
NavigateToLibraryTab: Router.NavigateToLibraryTab.bind(Router),
NavigateToLayoutPreview: Router.NavigateToLayoutPreview.bind(Router),
NavigateToSteamWeb: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateToSteamWeb.bind(
Router.WindowStore.GamepadUIMainWindowInstance,
),
NavigateToWebRoute: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateToWebRoute.bind(
Router.WindowStore.GamepadUIMainWindowInstance,
),
OpenSideMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenSideMenu.bind(
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
),
OpenQuickAccessMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenQuickAccessMenu.bind(
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
),
OpenMainMenu: Router.WindowStore?.GamepadUIMainWindowInstance?.MenuStore.OpenMainMenu.bind(
Router.WindowStore.GamepadUIMainWindowInstance.MenuStore,
),
CloseSideMenus: Router.CloseSideMenus.bind(Router),
OpenPowerMenu: Router.OpenPowerMenu.bind(Router),
} as Navigation;

0 comments on commit f0379e5

Please sign in to comment.