UNPKG

@sacredcasuals/shared-lib

Version:

Shared game utilities and UI components for Sacred Casuals apps

1,419 lines (1,369 loc) 66.1 kB
import * as _capacitor_device from '@capacitor/device'; import * as PIXI from 'pixi.js'; import { Rectangle, Point, AbstractText, AnyTextStyle, AnyTextStyleOptions, Container as Container$1, FederatedPointerEvent, Sprite, Graphics, Texture, NineSliceSprite, DestroyOptions, Optional, Size, ContainerChild, ColorSource, EventMode, Ticker, PointData, TextStyleOptions, Color } from 'pixi.js'; import { Tween } from '@tweenjs/tween.js'; import { Howl } from 'howler'; import { Input as Input$1 } from '@pixi/ui'; import { Signal } from 'typed-signals'; import { AbstractText as AbstractText$1 } from 'pixi.js/lib/scene/text/AbstractText'; interface IAnimatable extends IDestroy { get juggler(): GameJuggler | null; set juggler(value: GameJuggler | null); advanceTime(delta: number): void; addToJuggler(): void; removeFromJuggler(): void; onRemovedFromJuggler(): void; } declare class GameDelayCall extends GameObject { private readonly _callback; private _totalDelta; private readonly _endDelta; constructor(juggler: GameJuggler, callback: Function, durationSec: number); advanceTime(delta: number): void; } interface TweenBezier { startPoint: { x: number; y: number; }; endPoint: { x: number; y: number; }; curviness: number; } interface TweenParams { [key: string]: any; bezier?: TweenBezier; } declare class GameTween extends Tween implements IAnimatable, IDestroy { private _isDestroyed; private _juggler; private _targetObject; private _isCompleted; private _onComplete; constructor(target: IDestroy, juggler: GameJuggler); get targetObject(): IDestroy | null; addToJuggler(): void; removeFromJuggler(): void; get juggler(): GameJuggler; set juggler(value: GameJuggler); get destroyed(): boolean; start(time?: number, overrideStartingValues?: boolean): this; delay(amount: number): this; repeatDelay(amount: number): this; stop(): this; end(): this; pause(time?: number): this; repeat(times: number): this; yoyoFix(easingFunction: (amount: number) => number): this; easing(easingFunction: (amount: number) => number): this; to(props: TweenParams, duration: number): this; calculateMidPoint(startPoint: { x: number; y: number; }, endPoint: { x: number; y: number; }, curviness: number): { x: number; y: number; }; onRemovedFromJuggler(): void; private onCompleteInternal; onComplete(callback?: (object: any) => void): this; advanceTime(delta: number): void; destroy(): void; } declare class GameJuggler extends GameObject { protected _animates: IAnimatable[]; readonly root: AbstractPixiRoot; constructor(root: AbstractPixiRoot, parentJuggler: GameJuggler | null); advanceTime(delta: number): void; delayCall(callback: Function, durationSec: number): GameDelayCall; tween(target: any, duration: number, params: TweenParams): GameTween; removeTweens(animatable?: IAnimatable | null): void; removeAnimatable(animatable?: IAnimatable | null): void; addAnimatable(animatable: IAnimatable | null): void; purge(): void; destroy(): void; } interface IPoolable extends IDestroy { onReturnToPool(): void; onGetFromPool(pool: GamePool): void; } declare class GamePool extends GameObject { private _allObjects; private _pool; private _creator; constructor(creator: () => IPoolable); destroy(): void; removeFromPool(obj: IPoolable): void; returnToPool(obj: IPoolable): void; getFromPool(): IPoolable; returnAllToPool(): void; } interface IDestroy { destroy(): void; get destroyed(): boolean; } declare class GameObject implements IDestroy, IPoolable, IAnimatable { protected _isDestroyed: boolean; protected _juggler: GameJuggler | null; advanceTime(delta: number): void; addToJuggler(): void; onRemovedFromJuggler(): void; removeFromJuggler(): void; get juggler(): GameJuggler | null; set juggler(value: GameJuggler); get destroyed(): boolean; static destroy(object: any): null; onReturnToPool(): void; onGetFromPool(pool: GamePool): void; destroy(): void; } declare class LibraryText extends GameObject { readonly fontName: string; readonly root: AbstractPixiRoot; constructor(root: AbstractPixiRoot, fontName: string); unloadAssets(): void; destroy(): void; createBitmapText(txt: string, maxWidth: number, maxHeight: number, align?: PIXI.TextStyleAlign, fontSize?: number): PIXI.BitmapText; private fitText; } declare class GameView extends PIXI.Container implements IDestroy, IAnimatable { root: AbstractPixiRoot; constructor(...args: any[]); onResize(): void; set interactive(value: boolean); protected get pulsatingDisplayObject(): GameView; protected _pulsateTween?: GameTween; startPulsating(scaleDiff?: number, time?: number): void; continuePulsating(): void; stopPulsating(): void; protected _juggler?: GameJuggler; advanceTime(delta: number): void; addToJuggler(): void; removeFromJuggler(): void; onRemovedFromJuggler(): void; get juggler(): GameJuggler; set juggler(value: GameJuggler); destroyChildren(): void; destroy(): void; } declare class Placer extends GameView { private _content; constructor(root: AbstractPixiRoot, x: number, y: number, width: number, height: number, pivotX: number, pivotY: number); get content(): GameView; clear(): Placer; place(child: PIXI.Container): Placer; fitWidth(shouldFitIfBigger?: boolean, shouldFitIfSmaller?: boolean): Placer; fitHeight(shouldFitIfBigger?: boolean, shouldFitIfSmaller?: boolean): Placer; alignLeft(): Placer; alignCenter(offsetX?: number, offsetY?: number): Placer; alignCenterTop(): Placer; alignCenterBottom(): Placer; destroy(): void; } declare class AtlasTextureMold extends GameObject { symbol: string; bounds: Rectangle; origin: Point; tint_color: number; static fromJSON(o: Record<string, any>): AtlasTextureMold; destroy(): void; } declare class AtlasMold extends GameObject { private static readonly SCALE_FACTOR; file: string; atlasTextureMolds: AtlasTextureMold[]; get scaleFactor(): number; static extractScaleFactor(filename: string): number; static fromJSON(o: Record<string, any>): AtlasMold; static stripDotSuffix(filename: string): string; static stripPath(filename: string, separator?: string): string; static stripPathAndDotSuffix(filename: string, separator?: string): string; destroy(): void; } declare class TextureGroupMold extends GameObject { scaleFactor: number; atlasMolds: AtlasMold[]; static fromJSON(o: Record<string, any>): TextureGroupMold; destroy(): void; } declare class LibraryMold extends GameObject { movieMolds: MovieMold[]; textureGroups: TextureGroupMold[]; static fromJSON(data: Record<string, any>, mult?: number): LibraryMold; destroy(): void; bestTextureGroupForScaleFactor(scaleFactor: number): TextureGroupMold | null; private static compareInts; } declare class MovieLayer extends GameObject { private _currentDisplay; private _displaysByFrames; private _library; private _layerMold; constructor(movie: Movie, layerMold: MovieLayerMold, library: LibraryFlump); destroy(): void; drawFrame(frameNumber: number): void; } declare class Movie extends Container { static STOPPED: number; static PLAYING: number; static FIRST_FRAME: string; static LAST_FRAME: string; onLabelPassed: ((movie: Movie, label: string) => void) | null; onPlayToPositionComplete?: ((movie: Movie) => void) | null; protected _stopFrame: number; protected _layers: MovieLayer[]; protected _startFrame: number; protected _isPlayRangeLoop: boolean; protected _shouldDisposeOnComplete: boolean; protected _currentFrame: number; protected _numFrames: number; constructor(mold: MovieMold, library: LibraryFlump); build(): void; destroy(): void; removeFromParent(): void; getFrameForLabel(label: string): number; goTo(position: string): void; playLoop(): Movie; playOnce(shouldDispose: boolean): Movie; playRange(positionFrom?: string, positionTo?: string, loop?: boolean, shouldDispose?: boolean): Movie; playToPosition(positionTo?: string): Movie; stop(): Movie; private drawCurrentFrame; advanceTime(dt: number): void; } interface DisplayObjectFrameState { x: number; y: number; scaleX: number; scaleY: number; skewX: number; skewY: number; pivotX: number; pivotY: number; alpha: number; visible: boolean; } declare class LibraryFlump extends GameObject { static readonly FLUMP_LABEL = "label"; static readonly FLUMP_CLASS = "CLASS:"; static readonly FLUMP_PLACER = "PLACER:"; static readonly FLUMP_CONTENT = "CONTENT"; static readonly FLUMP_IGNORE = "IGNORE"; static readonly FLUMP_STATE_UP = "STATE_UP"; static readonly FLUMP_STATE_DOWN = "STATE_DOWN"; static readonly FLUMP_BOX = "BOX"; static readonly FLUMP_CHECK = "CHECK"; static readonly FLUMP_TEXT = "TEXT:"; private name; private creatorsMap; private libraryMold; readonly pixiRoot: AbstractPixiRoot; constructor(pixiRoot: AbstractPixiRoot); unloadAssets(): void; init(name: string, libraryMold: LibraryMold): void; getMovieMoldBySymbol(symbol: string): MovieMold | null; getTexture(name: string): PIXI.Texture | undefined; createImage(textureName: string): PIXI.Sprite; createMovie(movieName: string): Movie; createContainer(containerName: string): Container; create(symbolName: string): PIXI.Container<PIXI.ContainerChild>; protected createContainerByClassName(className: string, movieMold: MovieMold): Container | null; applyFrameState(displayObject: PIXI.Container, state: DisplayObjectFrameState): void; destroy(): void; private addCreator; } declare class KeyframeMold extends GameObject implements DisplayObjectFrameState { index: number; /** The length of this keyframe in frames. */ duration: number; /** The symbol of the image or movie in this keyframe, or null if there is nothing in it. */ ref: string | null; /** The label on this keyframe, or null if there isn't one */ label: string | null; /** Exploded values from matrix */ x: number; y: number; scaleX: number; scaleY: number; skewX: number; skewY: number; /** Transformation point */ pivotX: number; pivotY: number; alpha: number; visible: boolean; /** Is this keyframe tweened? */ tweened: boolean; /** Tween easing. Only valid if tweened==true. */ ease: number; static fromJSON(o: Record<string, any>, mult?: number): KeyframeMold; private static extractNested; private static extract; } declare class FrameMold implements DisplayObjectFrameState { ref: string | null; x: number; y: number; scaleX: number; scaleY: number; skewX: number; skewY: number; pivotX: number; pivotY: number; alpha: number; tintColor: string | null; visible: boolean; } declare class MovieLayerMold extends GameObject { name: string; keyframeMolds: KeyframeMold[]; framesMolds: (FrameMold | null)[]; get framesCount(): number; static fromJSON(o: Record<string, any>, mult?: number): MovieLayerMold; private initFrames; destroy(): void; } declare class MovieMold extends GameObject { symbol: string; layers: MovieLayerMold[]; labels: string[]; get flumpClassLabel(): string; getLayerMoldByName(name: string): MovieLayerMold | null; static fromJSON(o: Record<string, any>, mult?: number): MovieMold; destroy(): void; private fillLabels; } declare class Container extends GameView { protected _mold: MovieMold; protected _library: LibraryFlump; constructor(mold: MovieMold, library: LibraryFlump); clone(): Container; getPlacerByLabel(label: string): Placer; getMovieByLabel(label: string): Movie; getButtonByLabel(label: string): Button; getContainerByLabel(label: string): Container; getImageByLabel(label: string): PIXI.Sprite; build(): void; protected createPlacer(layerName: string, firstKeyFrameMold: KeyframeMold): Placer; protected createDisplayObject(layerName: string, firstKeyFrameMold: KeyframeMold): PIXI.Container<PIXI.ContainerChild> | null; } declare class Button extends Container { protected _onClickCallback: Function | null; protected _btnContent: Container; protected _alreadyClickedOnce: boolean; protected _isDown: boolean; protected _initialScale: number; protected _scaleTween?: GameTween; protected _clickDelayCall?: GameDelayCall; protected _shimmer: PIXI.Sprite | null; protected _shimmerTween: GameTween | null; private _text; private _textField; private _iconTextAlignContainer; constructor(mold: MovieMold, library: LibraryFlump); destroy(): void; startShimmer(): void; stopShimmer(): void; get pulsatingDisplayObject(): Container; get content(): Container; protected _shouldClickOnlyOnce: boolean; set shouldClickOnlyOnce(value: boolean); protected _minDistance: number; set minDistance(value: number); protected _animTime: number; set animTime(value: number); protected _clicksBetweenDelay: number; get clicksBetweenDelay(): number; set clicksBetweenDelay(value: number); protected _unTouchAnimTime: number; get unTouchAnimTime(): number; set unTouchAnimTime(value: number); protected _minScale: number; set minScale(value: number); protected _isEnabled: boolean; get isEnabled(): boolean; set isEnabled(value: boolean); set clickCallback(value: Function | null); protected get textPlacer(): Placer; protected get animScale(): number; setText(txt: string): this; build(): void; protected initBoundsArea(): void; protected onTouch(): void; protected onUnTouch(): void; protected onScaleTweenComplete(): void; protected onTap(event: PIXI.FederatedPointerEvent): void; protected onTouched(event: PIXI.FederatedPointerEvent): void; protected addClickListener(): void; protected removeClickListener(): void; protected removeAllTweens(): void; } declare class Checkbox extends Container { payload: string; protected _checkFunction: Function | null; protected _bg: PIXI.Container | null; protected _check: PIXI.Container | null; protected _initialScale: number; protected _isDown: boolean; protected _isSelected: boolean; protected _isEnabled: boolean; get isSelected(): boolean; set isSelected(value: boolean); set checkCallback(value: Function); get isEnabled(): boolean; set isEnabled(value: boolean); build(): void; destroy(): void; protected addClickListener(): void; protected removeClickListener(): void; protected onTouched(event: PIXI.FederatedPointerEvent): void; protected onTap(event: PIXI.FederatedPointerEvent): void; protected onTouch(): void; protected onUnTouch(): void; protected changeState(): void; } declare class ClickArea extends Button { constructor(mold: MovieMold, library: LibraryFlump); build(): void; onTouch(): void; onUnTouch(): void; } declare class TabButton extends Button { protected _upState: PIXI.Container; protected _downState: PIXI.Container; constructor(mold: MovieMold, library: LibraryFlump); protected _isSelected: boolean; get isSelected(): boolean; set isSelected(value: boolean); build(): void; destroy(): void; protected onTouch(): void; protected onUnTouch(): void; protected onSelectedStateChange(): void; } type GameDispatcherListener = (sender?: GameObject | null, argument?: any | null) => void; declare class GameDispatcher extends GameObject { private _sender?; private _listeners?; constructor(sender?: any); add(listener: GameDispatcherListener, context: any): void; remove(listener: GameDispatcherListener): void; dispatch(argument?: any): void; hasListener(listener: GameDispatcherListener): boolean; removeAllListeners(): void; destroy(): void; } declare class TextInput extends Container { static hack_currentInputPlaceholder: string; onChange: GameDispatcher; onEnter: GameDispatcher; protected _input?: Input$1 | null; protected _inputText: string; protected _inputPlaceholderText: string; constructor(mold: MovieMold, library: LibraryFlump); get input(): Input$1 | null | undefined; get text(): string; set text(value: string); extractText(): string; build(): void; destroy(): void; protected onInputChange(val: string): void; protected onInputEnter(val: string): void; } declare class BackgroundEffectParticle extends GameView { protected _dx: number; protected _dy: number; protected _rotSpeed: number; constructor(root: AbstractPixiRoot, layerNum: number); protected get horizontalForce(): number; update(): void; protected createParticleImage(): PIXI.Sprite; } declare class BackgroundEffect extends GameView { private _particles; constructor(root: AbstractPixiRoot, particlesCount: number); advanceTime(): void; destroy(): void; protected createParticle(layer: number): BackgroundEffectParticle; protected distribution(): number[]; } declare class SpineMovie extends GameView { private readonly _spine; private readonly _touchableQuad?; private _durationDelayCall?; private _currentCallback?; constructor(skeleton: string, atlas: string); destroy(): void; addToJuggler(): void; removeFromJuggler(): void; advanceTime(time: number): void; playLoop(animationName: string, fromDelta?: number): this; playOnce(animationName: string, onComplete?: (() => void) | null): SpineMovie; playDuration(animationName: string, durationSec: number, onEndCallback: () => void): SpineMovie; stop(): this; private onAnimationComplete; } declare class LibrarySpine extends GameObject { private readonly _skeletonName; private readonly _atlasName; constructor(skeletonName: string, atlasName: string); unloadAssets(): void; createSpineMovie(): SpineMovie; destroy(): void; } interface AssetAlias { alias: string; src: string; isMultipack?: boolean; } declare class PixiAssetsLoader extends GameObject { private static referenceCounter; private loadedAssets; private onLoadCallbacks; private isLoading; private loadingQueue; private flumpLibs; private spineLibs; private textLibs; private _isLoaded; readonly root: AbstractPixiRoot; constructor(root: AbstractPixiRoot); get isLoaded(): boolean; private get assetsScaleFactorPath(); private get assetsFlumpDirPath(); private get assetsSpineDirPath(); getTextLib(libName: string): LibraryText; getFlumpLib(libName: string): LibraryFlump; getSpineLib(libName: string): LibrarySpine | undefined; enqueueFontFace(): Promise<void>; enqueueBitmapFont(fontFileName: string): void; private static flumpLibJsonFilePrefix; enqueueFlumpLib(name: string, isMultiatlas?: boolean, libInstance?: LibraryFlump | null): void; private static spineLibJsonFilePrefix; private static spineAtlasFilePrefix; enqueueSpineLib(name: string): void; enqueueAtlas(name: string, isMultiatlas?: boolean): void; enqueueFile(alias: AssetAlias): boolean; loadAssets(onLoad?: () => void): Promise<void>; private replaceFileNameInPath; unloadAssets(): Promise<void>; getTextureByName(alias: string): PIXI.Texture | undefined; unloadAssetByAlias(alias: string): void; getObjectByAlias(alias: string): any; destroy(): void; private incrementReferenceCount; private decrementReferenceCount; } declare class GameScreen extends GameView { assetsLoader: PixiAssetsLoader | null; protected _bgImage?: PIXI.Sprite | null; protected _bgParticleEffect: BackgroundEffect | null; protected _isAdded: boolean; constructor(); getAreaForHtml(): PIXI.Rectangle; get screenID(): string; destroy(): void; onAdded(): Promise<void>; getStateDescription(): string; loadAssets(onLoad?: () => void): Promise<void>; createBg(): void; protected getBgTexture(): PIXI.Texture<PIXI.TextureSource<any>> | undefined; protected createBgEffect(): void; onActivate(): void; onDeActivate(): void; onExit(): void; } declare class GameSplashScreen extends GameScreen { onShowed?: Function | null; onHide?: Function | null; onAdded(): Promise<void>; hide(): void; protected onShowComplete(): void; protected onHideComplete(): void; } declare class GameWaiter extends GameView { private _blackImage; private _spinner; private _isShowed; private _container; private _spinnerTween; private _blackTween; constructor(root: AbstractPixiRoot, container: PIXI.Container); destroy(): void; protected createSpinner(): Movie; show(): void; hide(): void; } declare class GameDialog extends GameView { static SHOW_TIME: number; assetsLoader: PixiAssetsLoader | null; protected _waiter: Movie | null; protected _dialog: GameView | null; protected _blackBack: PIXI.Graphics | null; protected _dialogContent: Container | null; protected _isInHideProcess: boolean; _shouldDisposeCallback?: ((dialog: GameDialog) => void) | null; get btnClose(): Button | undefined; protected get title(): string | null; protected get dialogContentMoldName(): string; protected get dialogScale(): number; protected get tabletMultiplier(): number; protected get backgroundAlpha(): number; protected get createDialogLib(): LibraryFlump; protected playShowSound(): void; loadAssets(onLoaded?: () => void): Promise<void>; onAdded(): void; destroy(): void; showWaiter(): void; hideWaiter(): void; createDialog(): void; show(): void; hide(): void; onButtonClose(): void; protected createBlackBack(): void; protected createBackgroundEffect(): void; protected createTitle(): void; protected getCenterX(): number; protected getCenterY(): number; protected hideDialog(): void; protected onDialogShowEnd(): void; protected playCloseSound(): void; protected disposeFromNavigator(): void; protected hideBlackBack(): void; } declare class GameDialogLayer extends GameView { hideAllDialogsWithType(dialogType: string): void; onResize(): void; } declare class GameScreenLayer extends GameView { onResize(): void; } declare class SplashLayer extends GameView { onResize(): void; } declare class UILayer extends GameView { onResize(): void; } declare class WaiterLayer extends GameView { onResize(): void; } declare class GameScreenNavigator extends GameScreen { protected _splashScreenClass: (new () => GameSplashScreen) | null; protected _splashScreen: GameSplashScreen | null; protected _isScreenChangingProcess: boolean; protected _gameWaiter: GameWaiter | null; protected _screenLayer: GameScreenLayer; protected _uiLayer: UILayer; protected _dialogLayer: GameDialogLayer; protected _splashLayer: SplashLayer; protected _waiterLayer: WaiterLayer; protected _incomingScreen: GameScreen | null; protected _dialogsQueue: GameDialog[]; constructor(); protected _currentScreen: GameScreen | null; getAreaForHtml(): Rectangle; get currentScreen(): GameScreen | null; getScreenFromHierarchy(targetClass: any): any; get isLoadingIncomingScreen(): boolean; getStateDescription(): string; setSplashScreenClass(splashScreenClass: (new () => GameSplashScreen)): void; destroy(): void; showDialog(dialog: GameDialog, enqueue?: boolean, replaceOthersOfSameType?: boolean): void; changeScreen<T extends GameScreen>(screen: T, withSplash: boolean): Promise<void>; showWaiter(): void; hideWaiter(): void; removeAllDialogs(): void; destroySplash(): void; protected loadIncomingScreen(): void; protected onIncomingScreenLoaded(): Promise<void>; private onDialogRemove; private showSplashScreen; onActivate(): void; onDeActivate(): void; onExit(): void; onResize(): void; } type PixiAssetsScaleFactor = 2 | 4; declare abstract class AbstractPixiRoot extends GameScreenNavigator { readonly app: AbstractApp; readonly pixi: PIXI.Application; readonly onScreenHierarchyChanged: GameDispatcher; readonly webglcontextlost: GameDispatcher; readonly webglcontextrestored: GameDispatcher; protected _currentPixiWidth: number; protected _currentPixiHeight: number; protected _scaleFactor: PixiAssetsScaleFactor; protected _fixedStageWidth: number; protected _safeAreaTop: number; protected _safeAreaBottom: number; protected _fixedStageHeight: number; protected _isInitialized: boolean; protected _pixiContainer: HTMLElement; protected _pixiContainerResizeObserver: ResizeObserver | null; protected static _isLoadKTX2Initialized: boolean; constructor(app: AbstractApp); get isInitialized(): boolean; destroy(): void; get scaleFactor(): PixiAssetsScaleFactor; static multiply(scaleFactor: PixiAssetsScaleFactor): 1 | 0.5; get fixedStageWidth(): number; get fixedStageHeight(): number; get safeZoneBottom(): number; get safeZoneTop(): number; get fixedStageSafeHeight(): number; adapt(size: number): number; deAdaptsize(size: number): number; lock(): void; unlock(): void; get uiLib(): LibraryFlump; get mainTextLib(): LibraryText; get dialogTitleTextLib(): LibraryText; init(pixiContainer: HTMLElement, options?: { backgroundColor: number; backgroundAlpha: number; }): Promise<void>; onResize(): void; createTextureByColor(color: PIXI.Color): PIXI.Texture<PIXI.TextureSource<any>>; } declare class GameSprite extends PIXI.Sprite implements IDestroy { needDestroyTexture: boolean; set interactive(value: boolean); destroy(): void; } declare abstract class AbstractInfoDialog extends GameDialog { protected _text: string; protected _tf?: AbstractText | null; protected _btnCallback?: Function | null; constructor(text: string, btnCallback?: Function | null); onAdded(): void; get tabletMultiplier(): number; destroy(): void; get dialogContentMoldName(): string; getCenterY(): number; createDialog(): void; protected getText(): string; protected getIcon(): PIXI.Container<PIXI.ContainerChild>; protected getButtonText(): string; protected onButtonClick(): void; } declare class QuadtreeNode<T> { private topRight; private topLeft; private bottomRight; private bottomLeft; private bounds; private minimumBounds; private objectContainer; private objectsInBounds; constructor(bounds: PIXI.Rectangle, minimumBounds: PIXI.Point); removeObject(object: T): void; private objectInBoundsHelper; objectInBounds(checkingBounds: PIXI.Rectangle): T[]; insert(object: T, objectBounds: PIXI.Rectangle): QuadtreeNode<T> | null; getObjects(): T[]; getBounds(): PIXI.Rectangle; } declare class Quadtree<T> { private root; private bounds; private minimumBounds; private objectNodeMapping; constructor(minX: number, minY: number, maxX: number, maxY: number, minimumSize?: number); insert(object: T, bounds: Rectangle): boolean; nodeForObject(object: T): QuadtreeNode<T> | undefined; remove(object: T): boolean; update(object: T, bounds: Rectangle): void; objectsInRectangle(rectangle: Rectangle): T[]; getRoot(): QuadtreeNode<T>; } declare class GameQuadtreeView extends GameView { private _quadtree; private _viewport; private _quadChildren; private _childrenPositions; private _invalidated; constructor(worldSpace: PIXI.Rectangle, maintainOrder?: boolean); advanceTime(delta: number): void; updateChild(child: PIXI.Container): void; addChild<U extends (PIXI.IRenderLayer | PIXI.ContainerChild)[]>(...children: U): U[0]; addChildAt<U extends PIXI.IRenderLayer | PIXI.ContainerChild>(child: U, index: number): U; removeChild<U extends (PIXI.IRenderLayer | PIXI.ContainerChild)[]>(...children: U): U[0]; get visibleViewport(): PIXI.Rectangle; get quadtree(): Quadtree<PIXI.Container<PIXI.ContainerChild>>; get width(): number; get height(): number; updateViewport(viewport: PIXI.Rectangle, force?: boolean): void; private updateChildrenPositions; } type PixiText = AbstractText; type AnyText = string | number | PixiText; type PixiTextClass = new ({ text, style, }: { text: string; style?: PixiTextStyle; [x: string]: any; }) => PixiText; type PixiTextStyle = AnyTextStyle | Partial<AnyTextStyleOptions>; declare function getTextView(text: AnyText): PixiText; /** TODO */ interface DragObject extends Container$1 { dragData: FederatedPointerEvent; dragging: number; dragPointerStart: Container$1; dragObjStart: Point; dragGlobalStart: Point; } declare const BUTTON_EVENTS: string[]; type ButtonEvent = (typeof BUTTON_EVENTS)[number]; type Padding = number | [number, number] | [number, number, number, number] | { left?: number; right?: number; top?: number; bottom?: number; }; type ViewType = Sprite | Graphics | Texture | string; type InputOptions = { bg: ViewType; textStyle: PixiTextStyle; TextClass: PixiTextClass; placeholder: string; value: string; maxLength: number; secure: boolean; align: 'left' | 'center' | 'right'; padding: Padding; cleanOnFocus: boolean; nineSliceSprite: [number, number, number, number]; addMask: boolean; }; /** * Container-based component that creates an input to read the user's text. * @example * new Input({ * bg: Sprite.from('input.png'), * placeholder: 'Enter text', * padding: { * top: 11, * right: 11, * bottom: 11, * left: 11 * } // alternatively you can use [11, 11, 11, 11] or [11, 11] or just 11 * }); */ declare class Input extends Container$1 { protected _bg: Container$1 | NineSliceSprite | Graphics; protected inputMask?: Container$1 | NineSliceSprite | Graphics; protected _cursor?: Sprite; protected _value: string; protected _secure: boolean; protected inputField?: PixiText; protected placeholder?: PixiText; protected editing: boolean; protected tick: number; protected lastInputData: string | null; protected activation: boolean; protected readonly options: InputOptions; protected input: HTMLInputElement | null; protected handleActivationBinding: () => void; protected onKeyUpBinding: (e: KeyboardEvent) => void; protected stopEditingBinding: () => void; protected onInputBinding: (e: InputEvent) => void; protected onPasteBinding: (e: any) => void; /** Fires when input loses focus. */ onEnter: Signal<(text: string) => void>; /** Fires every time input string is changed. */ onChange: Signal<(text: string) => void>; /** Top side padding */ paddingTop: number; /** Right side padding */ paddingRight: number; /** Bottom side padding */ paddingBottom: number; /** Left side padding */ paddingLeft: number; /** * Creates an input. * @param { number } options - Options object to use. * @param { Sprite | Graphics | Texture | string } options.bg - Background of the Input. * <br> Can be a string (name of texture) or an instance of Texture, Sprite or Graphics. * <br> If you want to use NineSliceSprite, you have to pass a text (name of texture) * or an instance of Texture as a parameter. * @param { PixiTextStyle } options.textStyle - Text style of the Input. * @param { string } options.placeholder - Placeholder of the Input. * @param { string } options.value - Value of the Input. * @param { number } options.maxLength - Max length of the Input. * @param { 'left' | 'center' | 'right' } options.align - Align of the Input. * @param { Padding } options.padding - Padding of the Input. * @param { number } options.padding.top - Top padding of the Input. * @param { number } options.padding.right - Right padding of the Input. * @param { number } options.padding.bottom - Bottom padding of the Input. * @param { number } options.padding.left - Left padding of the Input. * @param { boolean } options.cleanOnFocus - Clean Input on focus. * @param { boolean } options.addMask - Add mask to the Input text, so it is cut off when it does not fit. * @param { Array } options.nineSliceSprite - NineSliceSprite values for bg and fill ([number, number, number, number]). * <br> <b>!!! IMPORTANT:</b> To make it work, you have to pass a texture name or texture instance as a bg parameter. */ constructor(options: InputOptions); protected onInput(e: InputEvent): void; protected onKeyUp(e: KeyboardEvent): void; protected init(): void; set bg(bg: ViewType); get bg(): Container$1 | string; protected _add(key: string): void; protected _delete(): void; protected _startEditing(): void; protected createInputField(): void; protected handleActivation(): void; protected stopEditing(): void; protected update(dt: number): void; protected align(): void; protected getAlign(): 0 | 1 | 0.5; protected getCursorPosX(): number; /** Sets the input text. */ set value(text: string); /** Return text of the input. */ get value(): string; set secure(val: boolean); get secure(): boolean; /** * Set paddings * @param value - number, array of 4 numbers or object with keys: top, right, bottom, left * or: [top, right, bottom, left] * or: [top&bottom, right&left] * or: { * left: 10, * right: 10, * top: 10, * bottom: 10, * } */ set padding(value: Padding); get padding(): [number, number, number, number]; destroy(options?: DestroyOptions | boolean): void; /** * Sets width of a Input. * If nineSliceSprite is set, then width will be set to nineSliceSprite. * If nineSliceSprite is not set, then width will control components width as Container. * @param width - Width value. */ set width(width: number); /** Gets width of Input. */ get width(): number; /** * Sets height of a Input. * If nineSliceSprite is set, then height will be set to nineSliceSprite. * If nineSliceSprite is not set, then height will control components height as Container. * @param height - Height value. */ set height(height: number); /** Gets height of Input. */ get height(): number; setSize(value: number | Optional<Size, 'height'>, height?: number): void; protected createInputMask(bg: ViewType): void; protected updateInputMaskSize(): void; protected onPaste(e: any): void; } type ListType = 'horizontal' | 'vertical'; type ListOptions<C extends ContainerChild = ContainerChild> = { elementsMargin?: number; children?: C[]; padding?: number; vertPadding?: number; horPadding?: number; topPadding?: number; bottomPadding?: number; leftPadding?: number; rightPadding?: number; items?: C[]; }; /** * Container-based component for arranging Pixi containers one after another based on their sizes. * * Type option is used to set the direction of the arrangement. * * If type is not specified, it will be acting like a bidirectional, items will be arranged to fit horizontally, * after there is no space left, new line will be started, so items will be arranged like `inline-block` in css. * * It is used inside elements with repeatable content, like {@link Select} or {@link ScrollBox}. * @example * const list = new List({ * children: [ new Graphics().rect(0, 0, 50, 50).fill(0x000000), new Graphics().rect(0, 0, 50, 50).fill(0xFFFFFF), * ], * }); * * list.addChild(new Graphics().rect(0, 0, 50, 50)).fill(0x000000); */ declare class List<C extends ContainerChild = ContainerChild> extends Container$1<C> { protected options?: { type?: ListType; } & ListOptions<C>; /** Container, that holds all inner elements. */ view: Container$1; /** Arrange direction. */ protected _type: ListType; /** Returns all arranged elements. */ readonly children: C[]; constructor(options?: { type?: ListType; } & ListOptions<C>); /** * Initiates list component. * @param options */ init(options?: { type?: ListType; } & ListOptions<C>): void; /** * Set items arrange direction. * @param type - Arrange direction. */ set type(type: ListType); /** * Get items arrange direction. * @returns Arrange direction. */ get type(): ListType; /** * Set element margin. * @param margin - Margin between elements. */ set elementsMargin(margin: number); /** * Get element margin. * @returns Margin between elements. */ get elementsMargin(): number; /** * Set padding, overriding all padding options. * @param padding - Padding surrounding list elements and its border. */ set padding(padding: number); /** * Get padding. * @returns Padding surrounding list elements and its border. */ get padding(): number; /** * Set vertical padding, overriding all top and bottom padding options. * @param padding - Vertical padding between list border and its elements. */ set vertPadding(padding: number); /** * Get vertical padding. * @returns Vertical padding between list border and its elements. */ get vertPadding(): number; /** * Set horizontal padding, overriding all left and right padding options. * @param padding - Horizontal padding between list border and its elements. */ set horPadding(padding: number); /** * Get horizontal padding. * @returns Horizontal padding between list border and its elements. */ get horPadding(): number; /** * Set left padding. * @param padding - Left padding between list border and its elements. */ set leftPadding(padding: number); /** * Get left padding. * @returns Left padding between list border and its elements. */ get leftPadding(): number; /** * Set right padding. * @param padding - Right padding between list border and its elements. */ set rightPadding(padding: number); /** * Get right padding. * @returns Right padding between list border and its elements. */ get rightPadding(): number; /** * Set top padding. * @param padding - Top padding between list border and its elements. */ set topPadding(padding: number); /** * Get top padding. * @returns Top padding between list border and its elements. */ get topPadding(): number; /** * Set bottom padding. * @param padding - Bottom padding between list border and its elements. */ set bottomPadding(padding: number); /** * Get bottom padding. * @returns Bottom padding between list border and its elements. */ get bottomPadding(): number; /** * Arrange all elements basing in their sizes and component options. * Can be arranged vertically, horizontally or bidirectional. */ arrangeChildren(): void; /** * Removes items from the list. (Does not destroy them) * @param itemID - Item to remove (starting from 0). */ removeItem(itemID: number): void; } interface SlidingNumberOptions { constrain?: boolean; maxSpeed?: number; ease?: ConstrainEase; disableDragOutOfBounce?: boolean; } interface ConstrainEase { done: boolean; to: number; start(speed: number, pos: number, to: number): void; update(): number; } declare class SlidingNumber { position: number; constrain: boolean; min: number; max: number; maxSpeed: number; disableDragOutOfBounce: boolean; protected _ease: ConstrainEase; protected _offset: number; protected _prev: number; protected _speed: number; protected _hasStopped: boolean; protected _targetSpeed: number; protected _speedChecker: number; protected _grab: number; protected _activeEase: ConstrainEase | null; constructor(options?: SlidingNumberOptions); set value(n: number); get value(): number; grab(offset: number): void; hold(newPosition: number): void; slide(instant?: boolean): void; get moveAmount(): number; protected _updateDefault(): void; protected _updateConstrain(instant?: boolean): void; } interface TrackpadOptions { /** override the easing function when constraining */ xEase?: ConstrainEase; yEase?: ConstrainEase; maxSpeed?: number; constrain?: boolean; disableEasing?: boolean; disableDragOutOfBounce?: boolean; } /** Easing controller for the {@link ScrollBox}. */ declare class Trackpad { xAxis: SlidingNumber; yAxis: SlidingNumber; protected _isDown: boolean; protected _globalPosition: Point; protected _frame: Rectangle; protected _bounds: Rectangle; protected _dirty: boolean; protected disableEasing: boolean; constructor(options: TrackpadOptions); pointerDown(pos: Point): void; pointerUp(): void; pointerMove(pos: Point): void; update(): void; resize(w: number, h: number): void; setBounds(minX: number, maxX: number, minY: number, maxY: number): void; get x(): number; get y(): number; } type ScrollBoxOptions = { width: number; height: number; background?: ColorSource; type?: ListType; radius: number; disableDynamicRendering?: boolean; disableEasing?: boolean; disableDragOutOfBounce?: boolean; dragTrashHold?: number; globalScroll?: boolean; shiftScroll?: boolean; proximityRange?: number; proximityDebounce?: number; disableProximityCheck?: boolean; } & Omit<ListOptions, 'children'>; type ProximityEventData = { item: Container$1; index: number; inRange: boolean; }; /** * Scrollable view, for arranging lists of Pixi container-based elements. * * Items, that are out of the visible area, are not rendered by default. * This behavior can be changed by setting 'disableDynamicRendering' option to true. * @example * new ScrollBox({ * background: 0XFFFFFF, * width: 200, * height: 300, * items: [ * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * new Graphics().drawRect(0, 0, 200, 50).fill(0x000000), * ], * }); */ declare class ScrollBox extends Container$1 { protected background: Graphics; protected borderMask: Graphics; protected lastWidth: number; protected lastHeight: number; protected __width: number; protected __height: number; protected _dimensionChanged: boolean; protected list: List; protected _trackpad: Trackpad; get trackpad(): Trackpad; protected isDragging: number; protected interactiveStorage: { item: Container$1; eventMode?: EventMode; }[]; protected visibleItems: Container$1[]; protected pressedChild: Container$1 | null; protected ticker: Ticker; protected options: ScrollBoxOptions; protected stopRenderHiddenItemsTimeout?: any; protected onMouseScrollBinding: (event: WheelEvent) => void; protected dragStarTouchPoint: Point; protected isOver: boolean; protected proximityRange: number; protected proximityStatusCache: boolean[]; protected lastScrollX: number | null; protected lastScrollY: number | null; protected proximityCheckFrameCounter: number; onProximityChange: Signal<(data: ProximityEventData) => void>; onScroll: Signal<(value: number) => void>; /** * @param options * @param {number} options.background - background color of the ScrollBox. * @param {number} options.width - width of the ScrollBox. * @param {number} options.height - height of the ScrollBox. * @param {number} options.radius - radius of the ScrollBox and its masks corners. * @param {number} options.elementsMargin - margin between elements. * @param {number} options.vertPadding - vertical padding of the ScrollBox. * @param {number} options.horPadding - horizontal padding of the ScrollBox. * @param {number} options.padding - padding of the ScrollBox (same horizontal and vertical). * @param {boolean} options.disableDynamicRendering - disables dynamic rendering of the ScrollBox, * so even elements the are not visible will be rendered. Be careful with this options as it can impact performance. * @param {boolean} [options.globalScroll=true] - if true, the ScrollBox will scroll even if the mouse is not over it. * @param {boolean} [options.shiftScroll=false] - if true, the ScrollBox will only scroll horizontally if the shift key * is pressed, and the type is set to 'horizontal'. */ constructor(options?: ScrollBoxOptions); /** * Initiates ScrollBox. * @param options * @param {number} options.background - background color of the ScrollBox. * @param {number} options.width - width of the ScrollBox. * @param {number} options.height - height of the ScrollBox. * @param {number} options.radius - radius of the ScrollBox and its masks corners. * @param {number} options.elementsMargin - margin between elements. * @param {number} options.vertPadding - vertical padding of the ScrollBox. * @param {number} options.horPadding - horizontal padding of the ScrollBox. * @param {number} options.padding - padding of the ScrollBox (same horizontal and vertical). * @param {boolean} options.disableDynamicRendering - disables dynamic rendering of the ScrollBox, * so even elements the are not visible will be rendered. Be careful with this options as it can impact performance. * @param {boolean} [options.globalScroll=true] - if true, the ScrollBox will scroll even if the mouse is not over it. * @param {boolean} [options.shiftScroll=false] - if true, the ScrollBox will only scroll horizontally if the shift key */ init(options: ScrollBoxOptions): void; protected get hasBounds(): boolean; /** * Adds array of items to a scrollable list. * @param {Container[]} items - items to add. */ addItems(items: Container$1[]): void; /** Remove all items from a scrollable list. */ removeItems(): void; /** * Adds one or more items to a scrollable list. * @param {Container} items - one or more items to add. */ addItem<T extends Container$1[]>(...items: T): T[0]; /** * Removes an item from a scrollable list. * @param {number} itemID - id of the item to remove. */ removeItem(itemID: number): void; /** * Checks if the item is visible or scrolled out of the visible part of the view.* Adds an item to a scrollable list. * @param {Container} item - item to check. * @param padding - proximity padding to consider the item visible. */ isItemVisible(item: Container$1, padding?: number): boolean; /** * Returns all inner items in a list. * @returns {Array<Container> | Array} - list of items. */ get items(): Container$1[] | []; /** * Set ScrollBox background. * @param {number | string} background - background color or texture. */ setBackground(background?: ColorSource): void; protected addMask(): void; protected makeScrollable(): void; protected setInteractive(interactive: boolean): void; protected get listHeight(): number; protected get listWidth(): number; /** * Controls item positions and visibility. * @param force */ resize(force?: boolean): void; protected onMouseScroll(event: WheelEvent): void; /** Makes it scroll down to the last element. */ scrollBottom(): void; /** Makes it scroll up to the first element. */ scrollTop(): void; protected renderAllItems(): void; protected stopRenderHiddenItems(): void; protected updateVisibleItems(): void; /** * Scrolls to the element with the given ID. * @param elementID */ scrollTo(elementID: number): void; /** * Scrolls to the given position. * @param position - x and y position object. * @param position.x - x position. * @param position.y - y position. */ scrollToPosition({ x, y }: Partial<PointData>): void; /** Gets component height. */ get height(): number; set height(value: number); /** Gets component width. */ get width(): number; set width(value: number); setSize(value: number | Optional<Size, 'height'>, height?: number): void; getSize(out?: Size): Size; /** Gets the curre