2023-01-15 20:22:54 -05:00
|
|
|
import { sleep } from '../utils';
|
2022-06-04 10:33:59 +02:00
|
|
|
import { Module, findModuleChild } from '../webpack';
|
|
|
|
|
|
|
|
|
|
export enum SideMenu {
|
|
|
|
|
None,
|
|
|
|
|
Main,
|
|
|
|
|
QuickAccess,
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-04 10:54:01 +02:00
|
|
|
export enum QuickAccessTab {
|
2022-06-04 10:33:59 +02:00
|
|
|
Notifications,
|
|
|
|
|
RemotePlayTogetherControls,
|
|
|
|
|
VoiceChat,
|
|
|
|
|
Friends,
|
|
|
|
|
Settings,
|
|
|
|
|
Perf,
|
|
|
|
|
Help,
|
|
|
|
|
Decky,
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-09 09:34:09 -05:00
|
|
|
export enum DisplayStatus {
|
|
|
|
|
Invalid = 0,
|
|
|
|
|
Launching = 1,
|
|
|
|
|
Uninstalling = 2,
|
|
|
|
|
Installing = 3,
|
|
|
|
|
Running = 4,
|
|
|
|
|
Validating = 5,
|
|
|
|
|
Updating = 6,
|
|
|
|
|
Downloading = 7,
|
|
|
|
|
Synchronizing = 8,
|
|
|
|
|
ReadyToInstall = 9,
|
|
|
|
|
ReadyToPreload = 10,
|
|
|
|
|
ReadyToLaunch = 11,
|
|
|
|
|
RegionRestricted = 12,
|
|
|
|
|
PresaleOnly = 13,
|
|
|
|
|
InvalidPlatform = 14,
|
|
|
|
|
PreloadComplete = 16,
|
|
|
|
|
BorrowerLocked = 17,
|
|
|
|
|
UpdatePaused = 18,
|
|
|
|
|
UpdateQueued = 19,
|
|
|
|
|
UpdateRequired = 20,
|
|
|
|
|
UpdateDisabled = 21,
|
|
|
|
|
DownloadPaused = 22,
|
|
|
|
|
DownloadQueued = 23,
|
|
|
|
|
DownloadRequired = 24,
|
|
|
|
|
DownloadDisabled = 25,
|
|
|
|
|
LicensePending = 26,
|
|
|
|
|
LicenseExpired = 27,
|
|
|
|
|
AvailForFree = 28,
|
|
|
|
|
AvailToBorrow = 29,
|
|
|
|
|
AvailGuestPass = 30,
|
|
|
|
|
Purchase = 31,
|
|
|
|
|
Unavailable = 32,
|
|
|
|
|
NotLaunchable = 33,
|
|
|
|
|
CloudError = 34,
|
|
|
|
|
CloudOutOfDate = 35,
|
|
|
|
|
Terminating = 36,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type AppOverview = {
|
2022-10-24 20:33:40 -04:00
|
|
|
appid: string;
|
|
|
|
|
display_name: string;
|
|
|
|
|
display_status: DisplayStatus;
|
|
|
|
|
sort_as: string;
|
|
|
|
|
};
|
2022-07-09 09:34:09 -05:00
|
|
|
|
2022-12-12 16:48:52 -07:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 15:07:47 +02:00
|
|
|
export interface Router {
|
2022-12-12 16:48:52 -07:00
|
|
|
WindowStore?: WindowStore;
|
2022-06-04 10:33:59 +02:00
|
|
|
CloseSideMenus(): void;
|
2022-06-04 13:42:23 -04:00
|
|
|
Navigate(path: string): void;
|
2022-10-24 20:33:40 -04:00
|
|
|
NavigateToAppProperties(): void;
|
2022-06-04 10:33:59 +02:00
|
|
|
NavigateToExternalWeb(url: string): void;
|
2022-10-24 20:33:40 -04:00
|
|
|
NavigateToInvites(): void;
|
2022-12-12 16:48:52 -07:00
|
|
|
NavigateToChat(): void;
|
|
|
|
|
NavigateToLibraryTab(): void;
|
|
|
|
|
NavigateToLayoutPreview(e: unknown): void;
|
2022-06-04 10:33:59 +02:00
|
|
|
OpenPowerMenu(unknown?: any): void;
|
2022-08-17 21:55:50 +02:00
|
|
|
get RunningApps(): AppOverview[];
|
2022-07-09 09:34:09 -05:00
|
|
|
get MainRunningApp(): AppOverview | undefined;
|
2022-06-04 10:33:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const Router = findModuleChild((m: Module) => {
|
|
|
|
|
if (typeof m !== 'object') return undefined;
|
|
|
|
|
for (let prop in m) {
|
|
|
|
|
if (m[prop]?.Navigate && m[prop]?.NavigationManager) return m[prop];
|
|
|
|
|
}
|
|
|
|
|
}) as Router;
|
2022-12-12 16:48:52 -07:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 21:55:08 -05:00
|
|
|
export let Navigation = {} as Navigation;
|
|
|
|
|
|
|
|
|
|
try {
|
2023-01-15 20:22:54 -05:00
|
|
|
(async () => {
|
|
|
|
|
// With how much Valve is changing these, you really shouldn't use them directly, instead see Navigation
|
|
|
|
|
let InternalNavigators: any;
|
|
|
|
|
function initInternalNavigators() {
|
|
|
|
|
try {
|
|
|
|
|
InternalNavigators = findModuleChild((m: any) => {
|
|
|
|
|
if (typeof m !== 'object') return undefined;
|
|
|
|
|
for (let prop in m) {
|
|
|
|
|
if (m[prop]?.GetNavigator) {
|
|
|
|
|
return m[prop];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})?.GetNavigator();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('[DFL:Router]: Failed to init internal navigators, trying again');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
initInternalNavigators();
|
|
|
|
|
while (!InternalNavigators?.AppProperties) {
|
|
|
|
|
console.log('[DFL:Router]: Trying to init internal navigators again');
|
|
|
|
|
await sleep(100);
|
|
|
|
|
initInternalNavigators();
|
|
|
|
|
}
|
|
|
|
|
console.log("got navigators", InternalNavigators)
|
|
|
|
|
const newNavigation = {
|
|
|
|
|
Navigate: Router.Navigate.bind(Router),
|
|
|
|
|
NavigateBack: Router.WindowStore?.GamepadUIMainWindowInstance?.NavigateBack.bind(
|
|
|
|
|
Router.WindowStore.GamepadUIMainWindowInstance,
|
|
|
|
|
),
|
|
|
|
|
NavigateToAppProperties: InternalNavigators?.AppProperties || Router.NavigateToAppProperties.bind(Router),
|
|
|
|
|
NavigateToExternalWeb: Router.NavigateToExternalWeb.bind(Router),
|
|
|
|
|
NavigateToInvites: InternalNavigators?.Invites || Router.NavigateToInvites.bind(Router),
|
|
|
|
|
NavigateToChat: Router.NavigateToChat.bind(Router),
|
|
|
|
|
NavigateToLibraryTab: InternalNavigators?.LibraryTab || 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;
|
|
|
|
|
|
|
|
|
|
Object.assign(Navigation, newNavigation);
|
|
|
|
|
})();
|
2023-01-12 21:55:08 -05:00
|
|
|
} catch (e) {
|
2023-01-15 20:22:54 -05:00
|
|
|
console.error('[DFL:Router]: Error initializing Navigation interface', e);
|
|
|
|
|
}
|