2024-07-28 18:17:52 -04:00
import Logger from '../logger' ;
2024-05-12 15:45:26 -04:00
import { Export , findModuleExport } from '../webpack' ;
feat(globals): Steam client reference (#92)
* change: Add SteamClient types
Steam Version: 1690583737
Steam Client Build Date: Sat, Jul 29 02:44 UTC -08:00
* new: Document some SteamClient interfaces
Using the SDH discord server, GitHub and some personal findings, I tried to document as much SteamClient functions as I can.
* new: Document some SteamClient interfaces - part 2
* new: Document some SteamClient interfaces - part 3
* new: Document some SteamClient interfaces - part 4
* new: Document some SteamClient interfaces - part 5
* new: Document some SteamClient interfaces - part 6
* new: Document some SteamClient interfaces - part 7
* change: Update interfaces to Steam Version 1691097434
Steam Version: 1691097434
Steam Client Build Date: Fri, Aug 4 04:54 UTC -08:00
* new: Document some SteamClient interfaces - part 8
* new: Document some SteamClient interfaces - part 9
* change: Update interfaces to Steam Version 1694466342
Steam Version: 1694466342
Steam Client Build Date: Tue, Sep 12 04:59 UTC +08:00
* new: Document some SteamClient interfaces - part 10
* new: Document some SteamClient interfaces - part 11
* new: Document some SteamClient interfaces - part 12
* new: Document some SteamClient interfaces - part 13
* new: Document some SteamClient interfaces - part 14
* change: Update interfaces to Steam Version 1698260427
Steam Version: 1698260427
Steam Client Build Date: Thu, Oct 26 2:40 AM UTC -08:00
* new: Document some SteamClient interfaces - part 10
* change: Update interfaces to Steam Version 1700160213
Steam Version: 1700160213
Steam Client Build Date: Fri, Nov 17 2:23 AM UTC +08:00
* docs(SteamClient): document some interfaces
* change: Fix formatting style
* docs(SteamClient): document protobufs & System.Report
* docs(SteamClient): document CMsgMonitorInfo
* docs(SteamClient): document remaining messages
* docs(SteamClient): update interfaces to Steam Version 1702515219
Steam Version: 1702515219
Steam Client Build Date: Thu, Dec 14 00:36 UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1704329464
Steam Version: 1704329464
Steam Client Build Date: Thu, Jan 4 12:23 AM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1705630720
Steam Version: 1705630720
Steam Client Build Date: Fri, Jan 19 1:58 AM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1706914901
Steam Version: 1706914901
Steam Client Build Date: Fri, Feb 2 8:46 PM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1709920887
Steam Version: 1709920887
Steam Client Build Date: Thu, Mar 7 5:29 PM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1710786209
Steam Version: 1710786209
Steam Client Build Date: Mon, Mar 18 7:07 PM UTC -08:00
* docs(SteamClient): document even more interfaces
* new: Document some SteamClient interfaces - part 15
* Fix QAM button bit number
* new: Document some SteamClient interfaces - part 16
* change: Update interfaces to Steam Version 1714854927
Steam Version: 1714854927
Steam Client Build Date: Sat, May 4 7:11 AM UTC -08:00
* change: Refactor and reorganize SteamClient
* docs(SteamClient): document more notification interfaces
* docs(SteamClient): document more interfaces
* docs(SteamClient): add some descriptions
* docs(SteamClient): remove duplicate types
* change: Fix rebase errors
* Updated ControllerStateChange
* Fix typo
* docs(SteamClient): update interfaces to Steam Version 1723601482
Steam Version: 1723601482
Steam Client Build Date: Wed, Aug 14 01:51 UTC -08:00
* docs(SteamClient): update interfaces to 1725654351
* docs(SteamClient): update interfaces to 1730416762
* docs(SteamClient): forgot some stuff
* docs(SteamClient): add missed interfaces
* docs(SteamClient): update enums
* docs(SteamClient): add some things and move stuff around
* docs(SteamClient): move shared enums/interfaces to a separate file
* docs(SteamClient): add more stuff
* docs(SteamClient): reword some things
* docs(SteamClient): new BrowserView things
* docs(SteamClient): review fixes
* move to src/globals
---------
Co-authored-by: ricewind012 <58827198+ricewind012@users.noreply.github.com>
Co-authored-by: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com>
Co-authored-by: Xander <xander@isxander.dev>
2025-04-23 10:20:48 -05:00
import { EDisplayStatus } from "../globals/steam-client/App" ;
2022-06-04 10:33:59 +02:00
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 ,
2023-04-28 22:25:56 -04:00
Music ,
Decky = 999 ,
2022-06-04 10:33:59 +02:00
}
2022-07-09 09:34:09 -05:00
export type AppOverview = {
2022-10-24 20:33:40 -04:00
appid : string ;
display_name : string ;
feat(globals): Steam client reference (#92)
* change: Add SteamClient types
Steam Version: 1690583737
Steam Client Build Date: Sat, Jul 29 02:44 UTC -08:00
* new: Document some SteamClient interfaces
Using the SDH discord server, GitHub and some personal findings, I tried to document as much SteamClient functions as I can.
* new: Document some SteamClient interfaces - part 2
* new: Document some SteamClient interfaces - part 3
* new: Document some SteamClient interfaces - part 4
* new: Document some SteamClient interfaces - part 5
* new: Document some SteamClient interfaces - part 6
* new: Document some SteamClient interfaces - part 7
* change: Update interfaces to Steam Version 1691097434
Steam Version: 1691097434
Steam Client Build Date: Fri, Aug 4 04:54 UTC -08:00
* new: Document some SteamClient interfaces - part 8
* new: Document some SteamClient interfaces - part 9
* change: Update interfaces to Steam Version 1694466342
Steam Version: 1694466342
Steam Client Build Date: Tue, Sep 12 04:59 UTC +08:00
* new: Document some SteamClient interfaces - part 10
* new: Document some SteamClient interfaces - part 11
* new: Document some SteamClient interfaces - part 12
* new: Document some SteamClient interfaces - part 13
* new: Document some SteamClient interfaces - part 14
* change: Update interfaces to Steam Version 1698260427
Steam Version: 1698260427
Steam Client Build Date: Thu, Oct 26 2:40 AM UTC -08:00
* new: Document some SteamClient interfaces - part 10
* change: Update interfaces to Steam Version 1700160213
Steam Version: 1700160213
Steam Client Build Date: Fri, Nov 17 2:23 AM UTC +08:00
* docs(SteamClient): document some interfaces
* change: Fix formatting style
* docs(SteamClient): document protobufs & System.Report
* docs(SteamClient): document CMsgMonitorInfo
* docs(SteamClient): document remaining messages
* docs(SteamClient): update interfaces to Steam Version 1702515219
Steam Version: 1702515219
Steam Client Build Date: Thu, Dec 14 00:36 UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1704329464
Steam Version: 1704329464
Steam Client Build Date: Thu, Jan 4 12:23 AM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1705630720
Steam Version: 1705630720
Steam Client Build Date: Fri, Jan 19 1:58 AM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1706914901
Steam Version: 1706914901
Steam Client Build Date: Fri, Feb 2 8:46 PM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1709920887
Steam Version: 1709920887
Steam Client Build Date: Thu, Mar 7 5:29 PM UTC -08:00
* docs(SteamClient): update interfaces to Steam Version 1710786209
Steam Version: 1710786209
Steam Client Build Date: Mon, Mar 18 7:07 PM UTC -08:00
* docs(SteamClient): document even more interfaces
* new: Document some SteamClient interfaces - part 15
* Fix QAM button bit number
* new: Document some SteamClient interfaces - part 16
* change: Update interfaces to Steam Version 1714854927
Steam Version: 1714854927
Steam Client Build Date: Sat, May 4 7:11 AM UTC -08:00
* change: Refactor and reorganize SteamClient
* docs(SteamClient): document more notification interfaces
* docs(SteamClient): document more interfaces
* docs(SteamClient): add some descriptions
* docs(SteamClient): remove duplicate types
* change: Fix rebase errors
* Updated ControllerStateChange
* Fix typo
* docs(SteamClient): update interfaces to Steam Version 1723601482
Steam Version: 1723601482
Steam Client Build Date: Wed, Aug 14 01:51 UTC -08:00
* docs(SteamClient): update interfaces to 1725654351
* docs(SteamClient): update interfaces to 1730416762
* docs(SteamClient): forgot some stuff
* docs(SteamClient): add missed interfaces
* docs(SteamClient): update enums
* docs(SteamClient): add some things and move stuff around
* docs(SteamClient): move shared enums/interfaces to a separate file
* docs(SteamClient): add more stuff
* docs(SteamClient): reword some things
* docs(SteamClient): new BrowserView things
* docs(SteamClient): review fixes
* move to src/globals
---------
Co-authored-by: ricewind012 <58827198+ricewind012@users.noreply.github.com>
Co-authored-by: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com>
Co-authored-by: Xander <xander@isxander.dev>
2025-04-23 10:20:48 -05:00
display_status : EDisplayStatus ;
2022-10-24 20:33:40 -04:00
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 ;
}
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 ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-06-04 10:33:59 +02:00
CloseSideMenus ( ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-06-04 13:42:23 -04:00
Navigate ( path : string ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-10-24 20:33:40 -04:00
NavigateToAppProperties ( ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-06-04 10:33:59 +02:00
NavigateToExternalWeb ( url : string ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-10-24 20:33:40 -04:00
NavigateToInvites ( ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-12-12 16:48:52 -07:00
NavigateToChat ( ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-12-12 16:48:52 -07:00
NavigateToLibraryTab ( ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
2022-12-12 16:48:52 -07:00
NavigateToLayoutPreview ( e : unknown ) : void ;
2024-07-28 18:17:52 -04:00
/** @deprecated use {@link Navigation} instead */
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
}
2024-05-12 15:45:26 -04:00
export const Router = findModuleExport ( ( e : Export ) = > e . Navigate && e . NavigationManager ) 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 ;
OpenSideMenu ( sideMenu : SideMenu ) : void ;
OpenQuickAccessMenu ( quickAccessTab? : QuickAccessTab ) : void ;
OpenMainMenu ( ) : void ;
OpenPowerMenu ( unknown ? : any ) : void ;
2024-07-28 18:51:08 -04:00
/** if calling this to perform navigation, call it after Navigate to prevent a race condition in desktop Big Picture mode that hides the overlay unintentionally */
2022-12-12 16:48:52 -07:00
CloseSideMenus ( ) : void ;
}
2023-01-12 21:55:08 -05:00
export let Navigation = { } as Navigation ;
2024-07-28 18:17:52 -04:00
const logger = new Logger ( "Navigation" ) ;
2023-01-12 21:55:08 -05:00
try {
2024-07-28 18:17:52 -04:00
function createNavigationFunction ( fncName : string , handler ? : ( win : any ) = > any ) {
return ( . . . args : any ) = > {
let win : WindowRouter | undefined ;
try {
win = window . SteamUIStore . GetFocusedWindowInstance ( ) ;
} catch ( e ) {
logger . warn ( "Navigation interface failed to call GetFocusedWindowInstance" , e ) ;
}
if ( ! win ) {
2024-10-04 23:52:04 -04:00
logger . warn ( "Navigation interface could not find any focused window. Falling back to Main Window Instance" ) ;
win = Router . WindowStore ? . GamepadUIMainWindowInstance || Router ? . WindowStore ? . SteamUIWindows ? . [ 0 ] ;
2024-07-28 18:17:52 -04:00
}
if ( win ) {
2023-01-16 09:12:16 -05:00
try {
2024-07-28 18:17:52 -04:00
const thisObj = handler && handler ( win ) ;
( thisObj || win ) [ fncName ] ( . . . args ) ;
2023-01-16 09:12:16 -05:00
} catch ( e ) {
2024-07-28 18:17:52 -04:00
logger . error ( "Navigation handler failed" , e ) ;
2023-01-16 09:12:16 -05:00
}
2024-07-28 18:17:52 -04:00
} else {
logger . error ( "Navigation interface could not find a window to navigate" ) ;
2023-01-16 09:12:16 -05:00
}
2023-01-15 20:22:54 -05:00
}
2024-07-28 18:17:52 -04:00
}
const newNavigation = {
Navigate : createNavigationFunction ( "Navigate" ) ,
NavigateBack : createNavigationFunction ( "NavigateBack" ) ,
NavigateToAppProperties : createNavigationFunction ( "AppProperties" , win = > win . Navigator ) ,
NavigateToExternalWeb : createNavigationFunction ( "ExternalWeb" , win = > win . Navigator ) ,
NavigateToInvites : createNavigationFunction ( "Invites" , win = > win . Navigator ) ,
NavigateToChat : createNavigationFunction ( "Chat" , win = > win . Navigator ) ,
NavigateToLibraryTab : createNavigationFunction ( "LibraryTab" , win = > win . Navigator ) ,
NavigateToLayoutPreview : Router.NavigateToLayoutPreview?.bind ( Router ) ,
NavigateToSteamWeb : createNavigationFunction ( "NavigateToSteamWeb" ) ,
OpenSideMenu : createNavigationFunction ( "OpenSideMenu" , win = > win . MenuStore ) ,
OpenQuickAccessMenu : createNavigationFunction ( "OpenQuickAccessMenu" , win = > win . MenuStore ) ,
OpenMainMenu : createNavigationFunction ( "OpenMainMenu" , win = > win . MenuStore ) ,
CloseSideMenus : createNavigationFunction ( "CloseSideMenus" , win = > win . MenuStore ) ,
OpenPowerMenu : Router.OpenPowerMenu?.bind ( Router ) ,
} as Navigation ;
2023-01-15 20:22:54 -05:00
2024-07-28 18:17:52 -04:00
Object . assign ( Navigation , newNavigation ) ;
2023-01-12 21:55:08 -05:00
} catch ( e ) {
2024-07-28 18:17:52 -04:00
logger . error ( 'Error initializing Navigation interface' , e ) ;
2023-01-15 20:22:54 -05:00
}