2022-10-24 20:33:40 -04:00
|
|
|
export * from './patcher';
|
2024-05-12 15:45:26 -04:00
|
|
|
export * from './static-classes';
|
2024-07-18 00:54:29 -04:00
|
|
|
export * from './react/react';
|
|
|
|
|
export * from './react/fc';
|
|
|
|
|
export * from './react/treepatcher';
|
2022-09-04 13:29:36 -04:00
|
|
|
|
2023-02-22 21:56:46 -05:00
|
|
|
declare global {
|
|
|
|
|
var FocusNavController: any;
|
|
|
|
|
var GamepadNavTree: any;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-04 13:29:36 -04:00
|
|
|
export function joinClassNames(...classes: string[]): string {
|
2022-10-24 20:33:40 -04:00
|
|
|
return classes.join(' ');
|
2022-09-04 13:29:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function sleep(ms: number) {
|
2022-10-24 20:33:40 -04:00
|
|
|
return new Promise((res) => setTimeout(res, ms));
|
2022-10-23 20:22:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-10-24 20:45:01 -04:00
|
|
|
* Finds the SP window, since it is a render target as of 10-19-2022's beta
|
2022-10-23 20:22:00 -04:00
|
|
|
*/
|
|
|
|
|
export function findSP(): Window {
|
2022-10-24 20:33:40 -04:00
|
|
|
// old (SP as host)
|
|
|
|
|
if (document.title == 'SP') return window;
|
|
|
|
|
// new (SP as popup)
|
2023-03-19 22:22:39 +02:00
|
|
|
const navTrees = getGamepadNavigationTrees();
|
2024-12-13 22:27:26 -05:00
|
|
|
return navTrees?.find((x: any) => x.m_ID == 'GamepadUI_Full_Root' || x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
|
2023-02-22 21:56:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the correct FocusNavController, as the Feb 22 2023 beta has two for some reason.
|
|
|
|
|
*/
|
|
|
|
|
export function getFocusNavController(): any {
|
|
|
|
|
return window.GamepadNavTree?.m_context?.m_controller || window.FocusNavController;
|
2022-10-24 20:33:40 -04:00
|
|
|
}
|
2023-03-19 22:22:39 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the gamepad navigation trees as Valve seems to be moving them.
|
|
|
|
|
*/
|
|
|
|
|
export function getGamepadNavigationTrees(): any {
|
|
|
|
|
const focusNav = getFocusNavController();
|
2024-09-16 19:29:38 -04:00
|
|
|
const context = focusNav?.m_ActiveContext || focusNav?.m_LastActiveContext;
|
2023-05-18 11:41:45 -07:00
|
|
|
return context?.m_rgGamepadNavigationTrees;
|
2023-03-19 22:22:39 +02:00
|
|
|
}
|