diff --git a/momentum/index.d.ts b/momentum/index.d.ts index 8bd2f8b..c1a5bf1 100644 --- a/momentum/index.d.ts +++ b/momentum/index.d.ts @@ -27,33 +27,39 @@ interface MapData { name: string; thumbnail: { urlLarge: string; - } + }; mainTrack: { difficulty: number; numZones: number; isLinear: boolean; - } - credits: { type: string, user: { alias: string } }[]; + }; + credits: { type: string; user: { alias: string } }[]; } declare type TimerEvent = TimerEventEnum[keyof TimerEventEnum]; declare interface TimerEventEnum { - Started: 0, - Finished: 1, - Stopped: 2, - Failed: 3, + Started: 0; + Finished: 1; + Stopped: 2; + Failed: 3; } declare type TimerState = TimerStateEnum[keyof TimerStateEnum]; declare interface TimerStateEnum { - NotRunning: 0, - Running: 1, - Practice: 2, + NotRunning: 0; + Running: 1; + Practice: 2; } declare interface GlobalEventNameMap { - 'OnMomentumTimerStateChange': (ent: unknown, type: TimerEvent) => void, - 'OnMomentumZoneChange': (enter: unknown, linear: unknown, curZone: unknown, curTrack: unknown, timerState: TimerState) => void, - 'OnSaveStateUpdate': (count: number, current: unknown, usingMenu: boolean) => void, - 'OnMomentumReplayStopped': () => void, + OnMomentumTimerStateChange: (ent: unknown, type: TimerEvent) => void; + OnMomentumZoneChange: ( + enter: unknown, + linear: unknown, + curZone: unknown, + curTrack: unknown, + timerState: TimerState + ) => void; + OnSaveStateUpdate: (count: number, current: unknown, usingMenu: boolean) => void; + OnMomentumReplayStopped: () => void; } diff --git a/p2ce/achievements.d.ts b/p2ce/achievements.d.ts index 4d3a7c2..df10184 100644 --- a/p2ce/achievements.d.ts +++ b/p2ce/achievements.d.ts @@ -1,17 +1,15 @@ - interface Achievement { - name: string; // Name of the achievement - index: number; // Index of the achievement (for use with the API) - achieved: boolean; // True if this has been achieved - available: boolean; // True if this is available - hide_until_achieved: boolean; // True if this is a "hidden" achievement. It should not be displayed in its full glory until achieved + name: string; // Name of the achievement + index: number; // Index of the achievement (for use with the API) + achieved: boolean; // True if this has been achieved + available: boolean; // True if this is available + hide_until_achieved: boolean; // True if this is a "hidden" achievement. It should not be displayed in its full glory until achieved flags: number; - count: number; // Current count, if a stat is involved with this achievement. The achievement is granted when count >= goal - goal: number; // Stat goal for this achievement + count: number; // Current count, if a stat is involved with this achievement. The achievement is granted when count >= goal + goal: number; // Stat goal for this achievement } declare namespace AchievementsAPI { - /** * Returns true if cheats were turned on at any point during this session */ diff --git a/p2ce/weapons.d.ts b/p2ce/weapons.d.ts index e3a888c..32d25cb 100644 --- a/p2ce/weapons.d.ts +++ b/p2ce/weapons.d.ts @@ -11,15 +11,15 @@ */ declare interface GlobalEventNameMap { - 'WeaponStateChange': (mode: WeaponStateMode, index: int32) => void, - 'WeaponSelect': (action: WeaponSelectAction) => void, + WeaponStateChange: (mode: WeaponStateMode, index: int32) => void; + WeaponSelect: (action: WeaponSelectAction) => void; } /** @group enum */ declare enum WeaponStateMode { - SWITCH = 0, - PICKUP = 1, - DROP = 2, + SWITCH = 0, + PICKUP = 1, + DROP = 2 } /** @group enum */ @@ -27,51 +27,51 @@ declare enum WeaponSelectAction { NEXT = 0, PREV = 1, SHOW = 2, - HIDE = 3, + HIDE = 3 } interface Weapon { - name: string; - classname: string; - viewmodel: string; - playermodel: string; + name: string; + classname: string; + viewmodel: string; + playermodel: string; - slot: number; - position: number; + slot: number; + position: number; - type: 'melee' | 'gun'; + type: 'melee' | 'gun'; - primary: { - usesPrimary: boolean; // True when this weapon uses primary ammo - usesClips: boolean; // True when this weapon uses clips - clipSize: number; // The clip size of the weapon - clipAmmo: number; // The ammo in the current clip - ammoType: string; // The name of the ammo, or an empty string if no name given - maxAmmo: number; // The max amount of primary ammo - ammo: number; // The amount of ammo remaining - }; + primary: { + usesPrimary: boolean; // True when this weapon uses primary ammo + usesClips: boolean; // True when this weapon uses clips + clipSize: number; // The clip size of the weapon + clipAmmo: number; // The ammo in the current clip + ammoType: string; // The name of the ammo, or an empty string if no name given + maxAmmo: number; // The max amount of primary ammo + ammo: number; // The amount of ammo remaining + }; - secondary: { - usesSecondary: boolean; // True when this weapon uses secondary ammo - usesClips: boolean; // True when this weapon uses clips - clipSize: number; // The clip size of the weapon - clipAmmo: number; // The ammo in the current clip - ammoType: string; // The name of the ammo, or an empty string if no name given - maxAmmo: number; // The max amount of secondary ammo - ammo: number; // The amount of ammo remaining - }; + secondary: { + usesSecondary: boolean; // True when this weapon uses secondary ammo + usesClips: boolean; // True when this weapon uses clips + clipSize: number; // The clip size of the weapon + clipAmmo: number; // The ammo in the current clip + ammoType: string; // The name of the ammo, or an empty string if no name given + maxAmmo: number; // The max amount of secondary ammo + ammo: number; // The amount of ammo remaining + }; } declare namespace WeaponsAPI { - function GetWeaponCount(): uint32; - function GetWeapons(): (Weapon | null)[]; - function GetActiveWeapon(): uint32; - function HasWeaponClass(classname: string): boolean; - function HasWeapon(id: uint32): boolean; - function GetWeaponInfo(id: uint32): Weapon | null; - function GetActiveWeaponInfo(): Weapon | null; - function CanSwitchToWeapon(id: uint32): boolean; - function SwitchToWeapon(id: uint32): boolean; - function GetWeaponIndexFromClass(classname: string): uint32; - function DropWeapon(id: uint32, throwVecX: number, throwVecY: number, throwVecZ: number): boolean; + function GetWeaponCount(): uint32; + function GetWeapons(): (Weapon | null)[]; + function GetActiveWeapon(): uint32; + function HasWeaponClass(classname: string): boolean; + function HasWeapon(id: uint32): boolean; + function GetWeaponInfo(id: uint32): Weapon | null; + function GetActiveWeaponInfo(): Weapon | null; + function CanSwitchToWeapon(id: uint32): boolean; + function SwitchToWeapon(id: uint32): boolean; + function GetWeaponIndexFromClass(classname: string): uint32; + function DropWeapon(id: uint32, throwVecX: number, throwVecY: number, throwVecZ: number): boolean; } diff --git a/shared/events.d.ts b/shared/events.d.ts index 2364a0d..eef9662 100644 --- a/shared/events.d.ts +++ b/shared/events.d.ts @@ -4,88 +4,88 @@ */ interface PanelEventNameMap { - 'AddStyle': (cls: string) => void, - 'AddStyleToEachChild': (cls: string) => void, - 'CarouselAutoScroll': (autoscroll_id: number) => void, - 'CarouselChildrenChanged': (panel: Panel) => void, - 'CarouselNavIncrementSelectedIndex':(inc: number) => void, - 'CarouselNavSetSelectedIndex': (index: number) => void, - 'DragStart': (source: unknown, info: DragEventInfo) => void, - 'DropInputFocus': () => void, - 'IfHasClassEvent': (cls: string, eventToFire: string) => void, - 'IfHoverOtherEvent': (otherPanelID: string, eventToFire: string) => void, - 'IfNotHasClassEvent': (cls: string, eventToFire: string) => void, - 'IfNotHoverOtherEvent': (otherPanelID: string, eventToFire: string) => void, - 'ImageFailedLoad': () => void, - 'MovePanelDown': (repeatCount: int32) => void, - 'MovePanelLeft': (repeatCount: int32) => void, - 'MovePanelRight': (repeatCount: int32) => void, - 'MovePanelUp': (repeatCount: int32) => void, - 'PagePanelDown': () => void, - 'PagePanelLeft': () => void, - 'PagePanelRight': () => void, - 'PagePanelUp': () => void, - 'PanelLoaded': () => void, - 'PanoramaCastVoteNo': () => void, - 'PanoramaCastVoteYes': () => void, - 'RemoveStyle': (cls: string) => void, - 'RemoveStyleFromEachChild': (cls: string) => void, - 'ResetCarouselMouseWheelCounts': () => void, - 'ScrollPanelDown': () => void, - 'ScrollPanelLeft': () => void, - 'ScrollPanelRight': () => void, - 'ScrollPanelUp': () => void, - 'ScrollToBottom': () => void, - 'ScrollToTop': () => void, - 'SetCarouselSelectedChild': (panel: Panel) => void, - 'SetChildPanelsSelected': (selected: boolean) => void, - 'SetInputFocus': () => void, - 'SetPanelEnabled': (enabled: boolean) => void, - 'SetPanelSelected': (selected: boolean) => void, - 'SwitchStyle': (slot: string, cls: string) => void, - 'TogglePanelSelected': () => void, - 'ToggleStyle': (cls: string) => void, - 'TriggerStyle': (cls: string) => void, - 'UpdateFocusAndDirtyChildStyles': () => void, + AddStyle: (cls: string) => void; + AddStyleToEachChild: (cls: string) => void; + CarouselAutoScroll: (autoscroll_id: number) => void; + CarouselChildrenChanged: (panel: Panel) => void; + CarouselNavIncrementSelectedIndex: (inc: number) => void; + CarouselNavSetSelectedIndex: (index: number) => void; + DragStart: (source: unknown, info: DragEventInfo) => void; + DropInputFocus: () => void; + IfHasClassEvent: (cls: string, eventToFire: string) => void; + IfHoverOtherEvent: (otherPanelID: string, eventToFire: string) => void; + IfNotHasClassEvent: (cls: string, eventToFire: string) => void; + IfNotHoverOtherEvent: (otherPanelID: string, eventToFire: string) => void; + ImageFailedLoad: () => void; + MovePanelDown: (repeatCount: int32) => void; + MovePanelLeft: (repeatCount: int32) => void; + MovePanelRight: (repeatCount: int32) => void; + MovePanelUp: (repeatCount: int32) => void; + PagePanelDown: () => void; + PagePanelLeft: () => void; + PagePanelRight: () => void; + PagePanelUp: () => void; + PanelLoaded: () => void; + PanoramaCastVoteNo: () => void; + PanoramaCastVoteYes: () => void; + RemoveStyle: (cls: string) => void; + RemoveStyleFromEachChild: (cls: string) => void; + ResetCarouselMouseWheelCounts: () => void; + ScrollPanelDown: () => void; + ScrollPanelLeft: () => void; + ScrollPanelRight: () => void; + ScrollPanelUp: () => void; + ScrollToBottom: () => void; + ScrollToTop: () => void; + SetCarouselSelectedChild: (panel: Panel) => void; + SetChildPanelsSelected: (selected: boolean) => void; + SetInputFocus: () => void; + SetPanelEnabled: (enabled: boolean) => void; + SetPanelSelected: (selected: boolean) => void; + SwitchStyle: (slot: string, cls: string) => void; + TogglePanelSelected: () => void; + ToggleStyle: (cls: string) => void; + TriggerStyle: (cls: string) => void; + UpdateFocusAndDirtyChildStyles: () => void; } interface GlobalEventNameMap { - 'AsyncEvent': (delay: duration, eventToFire: string) => void, - 'MainMenuResumeGame': () => void, - 'MainMenuPauseGame': () => void, - 'ShowPauseMenu': () => void, - 'HidePauseMenu': () => void, - 'ShowMainMenu': () => void, - 'HideMainMenu': () => void, - 'HudProcessInput': () => void, - 'HudThink': () => void, - 'ShowIntroMovie': () => void, - 'HideIntroMovie': () => void, - 'DemoPlaybackControl': (str: string, flt: float) => void, - 'Drawer_ExtendAndNavigateToTab': (tabid: string) => void, - 'Drawer_NavigateToTab': (tabid: string) => void, - 'Drawer_UpdateLobbyButton': (imgsrc: string, playercount: unknown) => void, - 'GameEventFired': (event: string) => void, - 'HideContentPanel': () => void, - 'LayoutReloaded': () => void, - 'MainMenuTabHidden': (tabid: string) => void, - 'MainMenuTabShown': (tabid: string) => void, - 'PageDown': () => void, - 'PageLeft': () => void, - 'PageRight': () => void, - 'PageUp': () => void, - 'PanoramaGameTimeJumpEvent': (time: duration) => void, - 'ReloadBackground': () => void, - 'ScrollDown': () => void, - 'ScrollLeft': () => void, - 'ScrollRight': () => void, - 'ScrollUp': () => void, - 'SettingsNavigateToPanel': (category: string, panel: Panel) => void, - 'ShowCenterPrintText': (message: string, priority: unknown) => void, - 'ShowContentPanel': () => void, - 'ShowVoteContextMenu': () => void, - 'StaticHudMenu_EntrySelected': (panel: Panel) => void, - 'UnloadLoadingScreenAndReinit': () => void, - 'AchievementInfoLoaded': () => void, - 'AchievementEarned': (player_index: number, achievement_index: number) => void, + AsyncEvent: (delay: duration, eventToFire: string) => void; + MainMenuResumeGame: () => void; + MainMenuPauseGame: () => void; + ShowPauseMenu: () => void; + HidePauseMenu: () => void; + ShowMainMenu: () => void; + HideMainMenu: () => void; + HudProcessInput: () => void; + HudThink: () => void; + ShowIntroMovie: () => void; + HideIntroMovie: () => void; + DemoPlaybackControl: (str: string, flt: float) => void; + Drawer_ExtendAndNavigateToTab: (tabid: string) => void; + Drawer_NavigateToTab: (tabid: string) => void; + Drawer_UpdateLobbyButton: (imgsrc: string, playercount: unknown) => void; + GameEventFired: (event: string) => void; + HideContentPanel: () => void; + LayoutReloaded: () => void; + MainMenuTabHidden: (tabid: string) => void; + MainMenuTabShown: (tabid: string) => void; + PageDown: () => void; + PageLeft: () => void; + PageRight: () => void; + PageUp: () => void; + PanoramaGameTimeJumpEvent: (time: duration) => void; + ReloadBackground: () => void; + ScrollDown: () => void; + ScrollLeft: () => void; + ScrollRight: () => void; + ScrollUp: () => void; + SettingsNavigateToPanel: (category: string, panel: Panel) => void; + ShowCenterPrintText: (message: string, priority: unknown) => void; + ShowContentPanel: () => void; + ShowVoteContextMenu: () => void; + StaticHudMenu_EntrySelected: (panel: Panel) => void; + UnloadLoadingScreenAndReinit: () => void; + AchievementInfoLoaded: () => void; + AchievementEarned: (player_index: number, achievement_index: number) => void; } diff --git a/shared/index.d.ts b/shared/index.d.ts index 632924a..4ed6e51 100644 --- a/shared/index.d.ts +++ b/shared/index.d.ts @@ -16,51 +16,51 @@ type Primitive = null | undefined | string | number | boolean | symbol | bigint; // From https://github.com/sindresorhus/type-fest/blob/main/source/basic.d.ts type JsonPrimitive = string | number | boolean | null; -type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}; +type JsonObject = { [Key in string]: JsonValue } & { [Key in string]?: JsonValue | undefined }; type JsonArray = JsonValue[] | readonly JsonValue[]; type JsonValue = JsonPrimitive | JsonObject | JsonArray; interface PanelTagNameMap { - 'Panel': Panel, - 'Button': Button, - 'TextEntry': TextEntry, - 'ToggleButton': ToggleButton, - 'Frame': Frame, - 'Image': Image, - 'Label': Label, - 'Movie': Movie - 'NumberEntry': NumberEntry, - 'ProgressBar': ProgressBar, - 'ResizeDragKnob': ResizeDragKnob, - 'ModelPanel': ModelPanel, - 'UICanvas': UICanvas, - 'BackbufferImagePanel': BackbufferImagePanel, - 'LoadingScreen': BackbufferImagePanel, - 'MainMenu': MainMenu, - 'SettingsSlider': SettingsSlider, + Panel: Panel; + Button: Button; + TextEntry: TextEntry; + ToggleButton: ToggleButton; + Frame: Frame; + Image: Image; + Label: Label; + Movie: Movie; + NumberEntry: NumberEntry; + ProgressBar: ProgressBar; + ResizeDragKnob: ResizeDragKnob; + ModelPanel: ModelPanel; + UICanvas: UICanvas; + BackbufferImagePanel: BackbufferImagePanel; + LoadingScreen: BackbufferImagePanel; + MainMenu: MainMenu; + SettingsSlider: SettingsSlider; } /** Defines a panel event source. */ declare type PanelEventSource = ValueOf; /** @group enum */ interface PanelEventSourceEnum { - PROGRAM: 0, - GAMEPAD: 1, - KEYBOARD: 2, - MOUSE: 3, - INVALID: 4, + PROGRAM: 0; + GAMEPAD: 1; + KEYBOARD: 2; + MOUSE: 3; + INVALID: 4; } /** Defines the current game state. */ declare type GameUIState = ValueOf; /** @group enum */ interface GameUIStateEnum { - INVALID: 0, - LOADINGSCREEN: 1, - INGAME: 2, - MAINMENU: 3, - PAUSEMENU: 4, - INTROMOVIE: 5 + INVALID: 0; + LOADINGSCREEN: 1; + INGAME: 2; + MAINMENU: 3; + PAUSEMENU: 4; + INTROMOVIE: 5; } /** Represents the info object provided by a DragEvent */ @@ -68,7 +68,7 @@ interface DragEventInfo { removePositionBeforeDrop: boolean; offsetX: number; offsetY: number; - displayPanel: Panel|null; + displayPanel: Panel | null; } declare type float = number; @@ -95,7 +95,7 @@ declare type Keyframes = unknown; type QueryOutput = T extends `.${string}` ? E[] : E; -/** Selects an element. +/** Selects an element. * @param selector The element selector. This can be an id selector (#xyz) or a class selector (.xyz) * @example Basic use. * ```js @@ -109,7 +109,7 @@ type QueryOutput = T extends `.${string}` ? E[] : E; * @alias "$" * @alias Query */ -declare function $(selector: T): QueryOutput|null; +declare function $(selector: T): QueryOutput | null; /** Namespace for common DOM manipulation operations. * For the query selector function, see {@link $ | $(...)} @@ -120,7 +120,6 @@ declare function $(selector: T): Que * ``` */ declare namespace $ { - namespace persistentStorage { /** Returns an integer representing the number of data items stored in the Storage object. */ const length: int32; @@ -129,13 +128,13 @@ declare namespace $ { function clear(): void; /** When passed a number n, this method will return the name of the nth key in the storage. */ - function key(n: int32): string|null; + function key(n: int32): string | null; /** When passed a key name, will return that key's value. * @example $.persistentStorage.getItem('settings.mainMenuMovie'); * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/pages/main-menu/main-menu.js#L241) */ - function getItem(keyName: string): T|null; + function getItem(keyName: string): T | null; /** When passed a key name and value, will add that key to the storage, or update that key's value if it already exists. * @example $.persistentStorage.setItem('dontShowAgain.' + key, true); @@ -155,21 +154,21 @@ declare namespace $ { * }); * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/pages/learn.js#L259) */ - function AsyncWebRequest(url: string, options?: { - // https://fetch.spec.whatwg.org/#methods - type: 'DELETE'|'GET'|'HEAD'|'OPTIONS'|'POST'|'PUT', - complete: (data: { - responseText: string, - statusText: string, - }) => void, - }): void; + function AsyncWebRequest( + url: string, + options?: { + // https://fetch.spec.whatwg.org/#methods + type: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT'; + complete: (data: { responseText: string; statusText: string }) => void; + } + ): void; /** Cancel a scheduled function. * @example * ``` * ConsoleNotify.scheduleOpacity = $.Schedule(5, () => {\/* ... *\/}); - * \/* ... *\/ - * + * \/* ... *\/ + * * $.CancelScheduled(ConsoleNotify.scheduleOpacity); * ``` * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/hud/console-notify.js#L8) @@ -183,7 +182,12 @@ declare namespace $ { * @example $.CreatePanel('Split', wrapper, '', { class: 'split--hud split--latest' }); * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/hud/comparisons.js#L107) */ - function CreatePanel(type: T, parent: Panel, id: string, properties?: Record): PanelTagNameMap[T]; + function CreatePanel( + type: T, + parent: Panel, + id: string, + properties?: Record + ): PanelTagNameMap[T]; function CreatePanel(type: string, parent: Panel, id: string, properties?: Record): Panel; /** Call during JS startup code to check if script is being reloaded */ @@ -217,8 +221,11 @@ declare namespace $ { /** Dispatch an event. * @example $.DispatchEvent('SettingsNavigateToPanel', matches.tabID, matches.panel); * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/pages/settings/search.js#L262) - */ - function DispatchEvent(event: T, ...args: T extends keyof GlobalEventNameMap ? Parameters : any[]): void; + */ + function DispatchEvent( + event: T, + ...args: T extends keyof GlobalEventNameMap ? Parameters : any[] + ): void; /** Dispatch an event to occur later. * @todo There don't appear to be any uses of this in Momentum UI. This needs to be documented! @@ -231,7 +238,7 @@ declare namespace $ { /** Find an element. * @todo There don't appear to be any uses of this in Momentum UI. This needs to be documented! */ - function FindChildInContext(...args: any[]): Panel|undefined; + function FindChildInContext(...args: any[]): Panel | undefined; /** Gets the root panel of the current Javascript context. * @example $.GetContextPanel().color = color; @@ -264,7 +271,7 @@ declare namespace $ { * @example $.Localize('#HudStatus_Spawn'); * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/hud/status.js#L47) */ - function Localize(str: string): string|null; + function Localize(str: string): string | null; /** Localize a string, but return empty string if the localization token is not found */ function LocalizeSafe(str: string): string; @@ -284,19 +291,26 @@ declare namespace $ { * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/components/chat.js#L8) * */ - function RegisterEventHandler(event: T, context: Panel|string, callback: PanelEventNameMap[T]): number; - function RegisterEventHandler(event: string, context: Panel|string, callback: Func): number; + function RegisterEventHandler( + event: T, + context: Panel | string, + callback: PanelEventNameMap[T] + ): number; + function RegisterEventHandler(event: string, context: Panel | string, callback: Func): number; /** Register a handler for an event that is not otherwise handled * @example $.RegisterForUnhandledEvent('OnMomentumTimerStateChange', this.onTimerEvent.bind(this));] * @returns A unique event identifier. * @see [Example](https://github.com/momentum-mod/panorama/blob/721f39fe40bad57cd93943278d3a3c857e9ae9d7/scripts/hud/comparisons.js#L18) */ - function RegisterForUnhandledEvent(event: T, callback: GlobalEventNameMap[T]): number; + function RegisterForUnhandledEvent( + event: T, + callback: GlobalEventNameMap[T] + ): number; function RegisterForUnhandledEvent(event: string, callback: Func): number; /** Register a key binding */ - function RegisterKeyBind(panel: Panel, key: string, event: Func|string): void; + function RegisterKeyBind(panel: Panel, key: string, event: Func | string): void; /** Schedule a function to be called later * @returns A unique event identifier. @@ -320,7 +334,6 @@ declare namespace $ { /** Log a warning */ function Warning(...args: any[]): void; - } /* ======================== PANEL ELEMENTS ======================== */ @@ -415,13 +428,13 @@ declare interface Panel { DeleteKeyframes(animation: Keyframes): void; /** Searches this element's direct children and returns a child with the specified id. */ - FindChild(id: string): Panel|null; + FindChild(id: string): Panel | null; - FindChildInLayoutFile(id: string): Panel|null; + FindChildInLayoutFile(id: string): Panel | null; FindChildrenWithClassTraverse(classname: string): Panel[]; - FindChildTraverse(id: string): Panel|null; + FindChildTraverse(id: string): Panel | null; GetAttributeInt(attribute: string, fallback: int32): int32; @@ -429,19 +442,19 @@ declare interface Panel { GetAttributeUInt32(attribute: string, fallback: uint32): uint32; - GetChild(index: int32): Panel|null; + GetChild(index: int32): Panel | null; GetChildCount(): int32; GetChildIndex(child: Panel): int32; - GetFirstChild(): Panel|null; + GetFirstChild(): Panel | null; - GetLastChild(): Panel|null; + GetLastChild(): Panel | null; GetLayoutFileDefine(def: string): unknown; - GetParent(): Panel|null; + GetParent(): Panel | null; GetPositionWithinWindow(): unknown; @@ -497,7 +510,15 @@ declare interface Panel { ScrollToBottom(): void; - ScrollToFitRegion(arg0: float, arg1: float, arg2: float, arg3: float, arg4: unknown, arg5: boolean, arg6: boolean): void; + ScrollToFitRegion( + arg0: float, + arg1: float, + arg2: float, + arg3: float, + arg4: unknown, + arg5: boolean, + arg6: boolean + ): void; ScrollToLeftEdge(): void; @@ -534,7 +555,7 @@ declare interface Panel { /** Sets an event trigger for this panel. * @example latestUpdateImage.SetPanelEvent('onactivate', () => SteamOverlayAPI.OpenURLModal(item.link)); * @see [Example](https://github.com/momentum-mod/panorama/blob/568f2d8de1303b86592a9a8602efd416f6a2f5bf/scripts/pages/main-menu/news.js#L57) - */ + */ SetPanelEvent(event: string, callback: Func): void; SetParent(parent: Panel): void; @@ -562,8 +583,7 @@ declare interface Panel { IsValid(): boolean; } -declare interface Button extends Panel { -} +declare interface Button extends Panel {} /** An interactive text input. * @todo These types are incomplete and unverified! @@ -630,8 +650,7 @@ declare interface NStateButton extends Button { ResetState(): void; } -declare interface HoldButton extends Button { -} +declare interface HoldButton extends Button {} declare interface Frame extends Panel { /** Sets the Frame content to the specified snippet. */ @@ -656,7 +675,7 @@ declare interface Image extends Panel { SetImage(path: string): void; - SetScaling(mode: 'stretch-to-cover-preserve-aspect'|'stretch-to-fit-preserve-aspect'): void; + SetScaling(mode: 'stretch-to-cover-preserve-aspect' | 'stretch-to-fit-preserve-aspect'): void; } declare interface Label extends Panel { @@ -750,7 +769,6 @@ declare interface ResizeDragKnob extends Panel { } interface FlexController { - /** Min value of the flex */ min: float; @@ -759,7 +777,6 @@ interface FlexController { } interface PoseParameter { - /** Starting (min) value of the pose param */ start: float; @@ -855,7 +872,7 @@ declare interface ModelPanel extends Panel { SetParticleSystemOffsetAngles(x: float, y: float, z: float): void; SetParticleSystemOffsetPosition(x: float, y: float, z: float): void; - + /** Returns an array of all sequences for this model */ GetSequences(): string[]; @@ -863,61 +880,61 @@ declare interface ModelPanel extends Panel { * @param sequence Sequence name */ SetSequence(sequence: string): void; - + /** Returns the current animation sequence for this model */ GetSequence(): string; - + /** Sets a single pose parameter * @param param Pose parameter to set, by name * @param value Value of the pose parameter */ SetPoseParameter(param: string, value: float): void; - + /** Get a pose parameter's current value * @param param Pose parameter to get, by name */ GetPoseParameter(param: string): float; - + /** Returns the number of pose parameters available for this model */ GetPoseParamCount(): int32; /** Returns an array of all pose parameters */ GetPoseParameters(): Record; - + /** Reset a single pose parameter to its default * @param param Pose parameter to reset, must be in range [0,GetPoseParamCount()) */ ResetPoseParam(param: int32): void; - + /** Resets all pose parameters to their default values */ ResetPoseParams(): void; - + /** Sets the current skin * @param skin Skin index, must be in range [0, GetSkinCount()) */ SetSkin(skin: int32): void; - + /** Returns the current skin */ GetSkin(): int32; - + /** Returns the total number of skins available to this model. * Use with SetSkin */ GetSkinCount(): int32; - + /** Set the LOD for this model * @param lod LOD level */ SetLOD(lod: int32): void; - + /** Returns the current LOD for this model */ GetLOD(): int32; - + /** Enable/disable cloth sim on a model, if it supports it * @param enable True to enable, false to disable */ SetClothSimulationEnabled(enable: boolean): void; - + /** Returns whether cloth simulation is enabled on this model. */ GetClothSimulationEnabled(): boolean; @@ -925,14 +942,14 @@ declare interface ModelPanel extends Panel { * The UI must take into account the min/max values specified in these structures */ GetFlexControllers(): Record; - + /** Set a flex controller value. Should be within the min/max returned by GetFlexControllers(), * but out of range values will still be used to render. * @param flexController Flex controller name * @param value Value of the flex */ SetFlexControl(flexController: string, value: float): void; - + /** Returns the current value associated with a flex controller * @param flexController Flex controller name */ @@ -940,8 +957,7 @@ declare interface ModelPanel extends Panel { } /** A console message target. */ -declare interface StaticConsoleMessageTarget extends Panel { -} +declare interface StaticConsoleMessageTarget extends Panel {} /** Renders 2d shapes in the UI. * @todo These types are incomplete and unverified! @@ -973,7 +989,13 @@ declare interface UICanvas extends Panel { * @param softness Softness of the line * @param color Color of the line */ - DrawSoftLinePointsDisconnected(count: number, coords: number[], thickness: number, softness: number, color: string): void; + DrawSoftLinePointsDisconnected( + count: number, + coords: number[], + thickness: number, + softness: number, + color: string + ): void; /** * @param count The number of points to draw. @@ -1016,13 +1038,20 @@ declare interface UICanvas extends Panel { * @param angleDelta Angle delta (in radians) * @param color Color of the wedge */ - DrawFilledWedge(cX: number, cY: number, radius: number, startAngle: number, angleDelta: number, color: string): void; + DrawFilledWedge( + cX: number, + cY: number, + radius: number, + startAngle: number, + angleDelta: number, + color: string + ): void; SetMaxDrawCommands(max: number): void; /** * Set current draw color - * @param color + * @param color */ SetDrawColor(color: string): void; @@ -1040,16 +1069,14 @@ declare interface UICanvas extends Panel { /** * Clear the canvas with the specified color - * @param color Clear color + * @param color Clear color */ Clear(color: string): void; } -declare interface BackbufferImagePanel extends Panel { -} +declare interface BackbufferImagePanel extends Panel {} -declare interface LoadingScreen extends Panel { -} +declare interface LoadingScreen extends Panel {} declare interface MainMenu extends Panel { IsMultiplayer(): boolean; @@ -1103,42 +1130,41 @@ declare interface SettingsEnumDropDown extends Panel { declare interface AvatarImage extends Panel { accountid: string; - + steamid: string; } declare interface BaseBlurTarget extends Panel { /** * Add a panel to the blur list - * @param panel + * @param panel */ AddBlurTarget(panel: Panel); /** * Remove a panel from the blur list - * @param panel + * @param panel */ RemoveBlurPanel(panel: Panel); } -declare interface TripleMonitorBackground extends Panel { -} +declare interface TripleMonitorBackground extends Panel {} declare type ClockType = ValueOf; /** @group enum */ declare interface ClockTypeEnum { - NONE: 'none', - REALTIME: 'realtime', - WALL: 'wall', - GAME: 'game', - GAMETICK: 'game-tick', - GAMESERVER: 'game-server' + NONE: 'none'; + REALTIME: 'realtime'; + WALL: 'wall'; + GAME: 'game'; + GAMETICK: 'game-tick'; + GAMESERVER: 'game-server'; } declare interface CountdownTimer extends Panel { timeleft: number; - + clocktype: ClockType; } @@ -1161,7 +1187,6 @@ declare namespace FriendsAPI { /** Gets the name of the player with the given XUID. This will only be known by the local user if the given user is in their friends list, on the same game server, in a chat room or lobby, or in a small group with the local user */ function GetNameForXUID(xuid: uint64): string; - } /** @group api */ @@ -1198,7 +1223,7 @@ declare namespace GameInterfaceAPI { function GetGameUIState(): GameUIState; /** Gets the current map name, or null if no map is active. */ - function GetCurrentMap(): string|null; + function GetCurrentMap(): string | null; } /** @group api */ @@ -1215,10 +1240,9 @@ declare namespace RichPresenceAPI { assets: { large_image: string; large_text: string; - } - } + }; + }; }): void; - } /** @group api */ @@ -1231,7 +1255,6 @@ declare namespace SteamOverlayAPI { /** Opens the steam overlay browser at the given URL in a modal window (no other windows in overlay, and overlay closes when window closes) */ function OpenURLModal(url: string): void; - } /** @group api */ @@ -1293,16 +1316,38 @@ declare namespace UiToolkitAPI { function ShowCustomLayoutContextMenu(targetPanelID: string, contentmenuID: string, layoutFile: string): unknown; /** Show a context menu with a specific id and using the given layout and parameters. targetPanelID can be the empty string in which case the cursor position is used to position the context menu. Returns context menu panel. */ - function ShowCustomLayoutContextMenuParameters(targetPanelID: string, contentmenuID: string, layoutFile: string, parameters: string): unknown; + function ShowCustomLayoutContextMenuParameters( + targetPanelID: string, + contentmenuID: string, + layoutFile: string, + parameters: string + ): unknown; /** Show a context menu with a specific id and using the given layout and parameters and call a function when dismissed. targetPanelID can be the empty string in which case the cursor position is used to position the context menu. Returns context menu panel. */ - function ShowCustomLayoutContextMenuParametersDismissEvent(targetPanelID: string, contentmenuID: string, layoutFile: string, parameters: string, dismissJsFunc: unknown): unknown; + function ShowCustomLayoutContextMenuParametersDismissEvent( + targetPanelID: string, + contentmenuID: string, + layoutFile: string, + parameters: string, + dismissJsFunc: unknown + ): unknown; /** Show a tooltip with a specifix id and using the given layout and parameters. */ - function ShowCustomLayoutParametersTooltip(targetPanelID: string, tooltipID: string, layoutFile: string, parameters: string): void; + function ShowCustomLayoutParametersTooltip( + targetPanelID: string, + tooltipID: string, + layoutFile: string, + parameters: string + ): void; /** Show a tooltip with a specifix id and using the given layout and parameters. Also apply a CSS class named "style" (to the tooltip root panel) in order to allow custom styling (eg. "Tooltip_NoArrow" to remove tooltip's arrow). */ - function ShowCustomLayoutParametersTooltipStyled(targetPanelID: string, tooltipID: string, layoutFile: string, parameters: string, style: string): void; + function ShowCustomLayoutParametersTooltipStyled( + targetPanelID: string, + tooltipID: string, + layoutFile: string, + parameters: string, + style: string + ): void; /** Show a popup that lets you specify a layout. */ function ShowCustomLayoutPopup(popupID: string, layoutFile: string): unknown; @@ -1314,7 +1359,12 @@ declare namespace UiToolkitAPI { function ShowCustomLayoutTooltip(targetPanelID: string, tooltipID: string, layoutFile: string): void; /** Show a tooltip with a specifix id and using the given layout. Also apply a CSS class named "style" (to the tooltip root panel) in order to allow custom styling (eg. "Tooltip_NoArrow" to remove tooltip's arrow). */ - function ShowCustomLayoutTooltipStyled(targetPanelID: string, tooltipID: string, layoutFile: string, style: string): void; + function ShowCustomLayoutTooltipStyled( + targetPanelID: string, + tooltipID: string, + layoutFile: string, + style: string + ): void; /** Show a popup with the given title add message and optional style. Button present: "OK". */ function ShowGenericPopup(title: string, message: string, style: string): unknown; @@ -1326,49 +1376,153 @@ declare namespace UiToolkitAPI { function ShowGenericPopupCancel(title: string, message: string, style: string, cancelJSFunc: unknown): unknown; /** Show a popup with the given title add message and optional style. You can specify the background style ("none", "dim" or "blur"). Button present: "Cancel". */ - function ShowGenericPopupCancelBgStyle(title: string, message: string, style: string, cancelJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupCancelBgStyle( + title: string, + message: string, + style: string, + cancelJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style. Button present: "OK". */ function ShowGenericPopupOk(title: string, message: string, style: string, okJSFunc: unknown): unknown; /** Show a popup with the given title add message and optional style. You can specify the background style ("none", "dim" or "blur"). Button present: "OK". */ - function ShowGenericPopupOkBgStyle(title: string, message: string, style: string, okJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupOkBgStyle( + title: string, + message: string, + style: string, + okJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style. Button present: "Ok"/"Cancel". */ - function ShowGenericPopupOkCancel(title: string, message: string, style: string, okJSFunc: unknown, cancelJSFunc: unknown): unknown; + function ShowGenericPopupOkCancel( + title: string, + message: string, + style: string, + okJSFunc: unknown, + cancelJSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style. You can specify the background style ("none", "dim" or "blur"). Button present: "Ok"/"Cancel". */ - function ShowGenericPopupOkCancelBgStyle(title: string, message: string, style: string, okJSFunc: unknown, cancelJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupOkCancelBgStyle( + title: string, + message: string, + style: string, + okJSFunc: unknown, + cancelJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of one button. */ - function ShowGenericPopupOneOption(title: string, message: string, style: string, optionName: string, optionJSFunc: unknown): unknown; + function ShowGenericPopupOneOption( + title: string, + message: string, + style: string, + optionName: string, + optionJSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of one button. You can specify the background style ("none", "dim" or "blur"). */ - function ShowGenericPopupOneOptionBgStyle(title: string, message: string, style: string, optionName: string, optionJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupOneOptionBgStyle( + title: string, + message: string, + style: string, + optionName: string, + optionJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of two button. */ - function ShowGenericPopupThreeOptions(title: string, message: string, style: string, option1Name: string, option1JSFunc: unknown, option2Name: string, option2JSFunc: unknown, option3Name: string, option3JSFunc: unknown): unknown; + function ShowGenericPopupThreeOptions( + title: string, + message: string, + style: string, + option1Name: string, + option1JSFunc: unknown, + option2Name: string, + option2JSFunc: unknown, + option3Name: string, + option3JSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of two button. You can specify the background style ("none", "dim" or "blur"). */ - function ShowGenericPopupThreeOptionsBgStyle(title: string, message: string, style: string, option1Name: string, option1JSFunc: unknown, option2Name: string, option2JSFunc: unknown, option3Name: string, option3JSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupThreeOptionsBgStyle( + title: string, + message: string, + style: string, + option1Name: string, + option1JSFunc: unknown, + option2Name: string, + option2JSFunc: unknown, + option3Name: string, + option3JSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of two button. */ - function ShowGenericPopupTwoOptions(title: string, message: string, style: string, option1Name: string, option1JSFunc: unknown, option2Name: string, option2JSFunc: unknown): unknown; + function ShowGenericPopupTwoOptions( + title: string, + message: string, + style: string, + option1Name: string, + option1JSFunc: unknown, + option2Name: string, + option2JSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style and let you specify the name of two button. You can specify the background style ("none", "dim" or "blur"). */ - function ShowGenericPopupTwoOptionsBgStyle(title: string, message: string, style: string, option1Name: string, option1JSFunc: unknown, option2Name: string, option2JSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupTwoOptionsBgStyle( + title: string, + message: string, + style: string, + option1Name: string, + option1JSFunc: unknown, + option2Name: string, + option2JSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style. Button present: "Yes"/"No". */ - function ShowGenericPopupYesNo(title: string, message: string, style: string, yesJSFunc: unknown, noJSFunc: unknown): unknown; + function ShowGenericPopupYesNo( + title: string, + message: string, + style: string, + yesJSFunc: unknown, + noJSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style. You can specify the background style ("none", "dim" or "blur"). Button present: "Yes"/"No". */ - function ShowGenericPopupYesNoBgStyle(title: string, message: string, style: string, yesJSFunc: unknown, noJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupYesNoBgStyle( + title: string, + message: string, + style: string, + yesJSFunc: unknown, + noJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup with the given title add message and optional style. Button present: "Yes"/"No"/"Cancel". */ - function ShowGenericPopupYesNoCancel(title: string, message: string, style: string, yesJSFunc: unknown, noJSFunc: unknown, cancelJSFunc: unknown): unknown; + function ShowGenericPopupYesNoCancel( + title: string, + message: string, + style: string, + yesJSFunc: unknown, + noJSFunc: unknown, + cancelJSFunc: unknown + ): unknown; /** Show a popup with the given title add message and optional style. You can specify the background style ("none", "dim" or "blur"). Button present: "Yes"/"No"/"Cancel". */ - function ShowGenericPopupYesNoCancelBgStyle(title: string, message: string, style: string, yesJSFunc: unknown, noJSFunc: unknown, cancelJSFunc: unknown, bgStyle: string): unknown; + function ShowGenericPopupYesNoCancelBgStyle( + title: string, + message: string, + style: string, + yesJSFunc: unknown, + noJSFunc: unknown, + cancelJSFunc: unknown, + bgStyle: string + ): unknown; /** Show a popup on the 'global popups top level window' that lets you specify a layout. */ function ShowGlobalCustomLayoutPopup(popupID: string, layoutFile: string): unknown; @@ -1380,7 +1534,12 @@ declare namespace UiToolkitAPI { function ShowSimpleContextMenu(targetPanelID: string, contentmenuID: string, items: unknown): unknown; /** Show a context menu with a specific id and populate the context menu item list using the given "items" array. Each elements of the items array is a javascript object of the form {label, jsCallback, style, icon}. targetPanelID can be the empty string in which case the cursor position is used to position the context menu. Returns context menu panel. */ - function ShowSimpleContextMenuWithDismissEvent(targetPanelID: string, contentmenuID: string, items: unknown, dismissJsFunc: unknown): unknown; + function ShowSimpleContextMenuWithDismissEvent( + targetPanelID: string, + contentmenuID: string, + items: unknown, + dismissJsFunc: unknown + ): unknown; /** Show a tooltip with the given text */ function ShowTextTooltip(targetPanelID: string, text: string): void; @@ -1398,7 +1557,13 @@ declare namespace UiToolkitAPI { function ShowTitleImageTextTooltip(targetPanelID: string, title: string, image: string, text: string): void; /** Show a tooltip with the giben title, image and text. Also apply a CSS class named "style" to allow custom styling. */ - function ShowTitleImageTextTooltipStyled(targetPanelID: string, title: string, image: string, text: string, style: string): void; + function ShowTitleImageTextTooltipStyled( + targetPanelID: string, + title: string, + image: string, + text: string, + style: string + ): void; /** Show a tooltip with the given title and text. */ function ShowTitleTextTooltip(targetPanelID: string, title: string, text: string): void; @@ -1408,14 +1573,12 @@ declare namespace UiToolkitAPI { /** Unregister a javascript callback previously registered with RegisterJSCallback. */ function UnregisterJSCallback(jsCallbackHandle: int32): void; - } /** @group api */ declare namespace UserAPI { /** Gets the XUID (steamid as integer) of the local player */ function GetXUID(): uint64; - } /** @group api */ diff --git a/shared/style.d.ts b/shared/style.d.ts index 9f50273..284edb6 100644 --- a/shared/style.d.ts +++ b/shared/style.d.ts @@ -10,17 +10,17 @@ declare interface Style { font: string; fontFamily: string; fontSize: number; - fontStyle: 'normal'|'italic'; - fontWeight: 'light'|'thin'|'normal'|'medium'|'bold'|'black'; + fontStyle: 'normal' | 'italic'; + fontWeight: 'light' | 'thin' | 'normal' | 'medium' | 'bold' | 'black'; letterSpacing: string; lineHeight: string; - textAlign: 'left'|'center'|'right'; - textDecoration: 'none'|'underline'|'line-through'; - textOverflow: 'ellipses'|'clip'|'shrink'|'noclip'; + textAlign: 'left' | 'center' | 'right'; + textDecoration: 'none' | 'underline' | 'line-through'; + textOverflow: 'ellipses' | 'clip' | 'shrink' | 'noclip'; textShadow: string; textShadowFast: string; textTransform: string; - whiteSpace: 'normal'|'nowrap'; + whiteSpace: 'normal' | 'nowrap'; // Background backgroundColor: string; @@ -32,8 +32,8 @@ declare interface Style { // Alignment align: string; - verticalAlign: 'bottom'|'center'|'top'; - horizontalAlign: 'left'|'center'|'right'; + verticalAlign: 'bottom' | 'center' | 'top'; + horizontalAlign: 'left' | 'center' | 'right'; // Layout position: string; @@ -42,7 +42,7 @@ declare interface Style { overflow: string; height: string; width: string; - flowChildren: 'none'|'left'|'right'|'up'|'down'; + flowChildren: 'none' | 'left' | 'right' | 'up' | 'down'; maxHeight: string; maxWidth: string; minHeight: string; @@ -142,6 +142,6 @@ declare interface Style { opacityMaskScrollUpDown: string; // Visibility - visibility: 'visible'|'collapse'; + visibility: 'visible' | 'collapse'; zIndex: number; }