From 3ca8c43a542b1049c4e203ad186e555401fbfbfe Mon Sep 17 00:00:00 2001 From: Mikhail Kozlov Date: Thu, 18 May 2023 11:40:41 -0700 Subject: [PATCH 1/2] feat(StaticClasses): add new GamepadUI classes --- src/deck-components/static-classes.ts | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/deck-components/static-classes.ts b/src/deck-components/static-classes.ts index 0b9d93e..c81c7b0 100644 --- a/src/deck-components/static-classes.ts +++ b/src/deck-components/static-classes.ts @@ -441,6 +441,69 @@ type AppDetailsClasses = Record< string >; +type GamepadUIClasses = Record< + | 'duration-app-launch' + | 'TransitionMenuDelay' + | 'PanelSection' + | 'PanelSectionTitle' + | 'Text' + | 'PanelSectionRow' + | 'Label' + | 'ComingSoon' + | 'LowBattery' + | 'ReallyLow' + | 'LowBatteryGauge' + | 'Remaining' + | 'EmptyNotifications' + | 'BatterySectionContainer' + | 'BatteryIcon' + | 'BatteryPercentageLabel' + | 'BatteryDetailsLabels' + | 'BatteryProjectedValue' + | 'BatteryProjectedLabel' + | 'ViewPlaceholder' + | 'FullHeight' + | 'Title' + | 'Container' + | 'Open' + | 'QuickAccessMenu' + | 'HeaderContainer' + | 'Menu' + | 'HeaderAndFooterVisible' + | 'TabContentColumn' + | 'Tabs' + | 'Tab' + | 'Selected' + | 'ItemFocusAnim-darkerGrey' + | 'ItemFocusAnim-darkerGrey-nocolor' + | 'VoiceTab' + | 'ItemFocusAnim-green' + | 'Blocked' + | 'TabPanelHidden' + | 'FriendsTitle' + | 'FriendsListTabPanel' + | 'PanelOuterNav' + | 'PanelExitAnchor' + | 'TabGroupPanel' + | 'FooterBoxShadow' + | 'AllTabContents' + | 'ContentTransition' + | 'ActiveTab' + | 'Up' + | 'Enter' + | 'EnterActive' + | 'Exit' + | 'ExitActive' + | 'Down' + | 'KeyboardButton' + | 'ItemFocusAnim-darkGrey' + | 'ItemFocusAnim-grey' + | 'ItemFocusAnimBorder-darkGrey' + | 'focusAnimation' + | 'hoverAnimation', + string +>; + export const quickAccessMenuClasses: QuickAccessMenuClasses = findModule( (mod) => typeof mod === 'object' && mod?.Title?.includes('quickaccessmenu'), ); @@ -476,3 +539,6 @@ export const appDetailsHeaderClasses: AppDetailsHeaderClasses = findModule( export const appDetailsClasses: AppDetailsClasses = findModule( (mod) => typeof mod === 'object' && mod?.HeaderLoaded?.includes('appdetails_'), ); +export const gamepadUIClasses: GamepadUIClasses = findModule( + (mod) => typeof mod === 'object' && mod?.BasicUiRoot?.includes('gamepadui_'), +); \ No newline at end of file From 18d341f82acf843ff830d1bf3d44678f3f2eda52 Mon Sep 17 00:00:00 2001 From: Mikhail Kozlov Date: Thu, 18 May 2023 11:41:45 -0700 Subject: [PATCH 2/2] fix(Utils): return null when SP not found --- src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index e87b167..a1fd37d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,7 +22,7 @@ export function findSP(): Window { if (document.title == 'SP') return window; // new (SP as popup) const navTrees = getGamepadNavigationTrees(); - return navTrees.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; + return navTrees?.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; } /** @@ -38,5 +38,5 @@ export function getFocusNavController(): any { export function getGamepadNavigationTrees(): any { const focusNav = getFocusNavController(); const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext; - return context.m_rgGamepadNavigationTrees; + return context?.m_rgGamepadNavigationTrees; }