From c05b302f9a575a8586f88c544eec40308d400d65 Mon Sep 17 00:00:00 2001 From: Rex Date: Mon, 25 Sep 2023 10:11:42 +0800 Subject: [PATCH] Update d.ts --- templates/ui/tweaker/Tweaker.d.ts | 106 ++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 34 deletions(-) diff --git a/templates/ui/tweaker/Tweaker.d.ts b/templates/ui/tweaker/Tweaker.d.ts index 79e1cf14c5..1a331a4248 100644 --- a/templates/ui/tweaker/Tweaker.d.ts +++ b/templates/ui/tweaker/Tweaker.d.ts @@ -1,3 +1,4 @@ +import BaseSizer from '../basesizer/BaseSizer'; import Sizer from '../sizer/Sizer'; import RoundRectangle from '../roundrectangle/RoundRectangle'; import CreateBackground from '../utils/build/CreateBackground'; @@ -45,51 +46,52 @@ declare namespace Tweaker { } } + interface IInputRowStyle { + background?: CreateBackground.IConfig, - interface IConfig extends Sizer.IConfig { - styles: { - itemWidth?: number, + title?: SimpleLabel.IConfig, - background?: CreateBackground.IConfig, + inputText?: InputText.IConfig, - inputRow?: { - background?: CreateBackground.IConfig, + inputTextArea?: InputTextArea.IConfig, - title?: SimpleLabel.IConfig, + slider?: { + track: RoundRectangle.IConfig, + indicator: RoundRectangle.IConfig, + thumb: RoundRectangle.IConfig, + }, - inputText?: InputText.IConfig, + list?: { + label?: SimpleLabel.IConfig, - inputTextArea?: InputTextArea.IConfig, + button?: IInteractiveLabelConfig, + }, - slider?: { - track: RoundRectangle.IConfig, - indicator: RoundRectangle.IConfig, - thumb: RoundRectangle.IConfig, - }, + button?: IButtonConfig, - list?: { - label?: SimpleLabel.IConfig, + checkbox?: Checkbox.IConfig, - button?: IInteractiveLabelConfig, - }, + toggleSwitch?: ToggleSwitch.IConfig, - button?: IButtonConfig, + colorInput?: ColorInput.IConfig, - checkbox?: Checkbox.IConfig, + proportion?: { + title?: number, + inputField?: number, + range?: { + slider?: number, + inputText?: number, + } + } + } - toggleSwitch?: ToggleSwitch.IConfig, + interface IConfig extends Sizer.IConfig { + styles: { + itemWidth?: number, - colorInput?: ColorInput.IConfig, + background?: CreateBackground.IConfig, - proportion?: { - title?: number, - inputField?: number, - range?: { - slider?: number, - inputText?: number, - } - } - }, + inputRow?: IInputRowStyle, folder?: { title?: SimpleLabel.IConfig, @@ -119,13 +121,40 @@ declare namespace Tweaker { } } + interface IInputHandlerConfig { + name?: string, + + baseClass?: BaseSizer, + + accept: ( + config: IAddInputConfig, + value: unknown + ) => boolean, + + build: ( + gameObject: BaseSizer, + style: IInputRowStyle + ) => void, + + setup?: ( + gameObject: BaseSizer, + config: IAddInputConfig, + setDefaults: boolean, + ) => void, + + displayValue?: ( + gameObject: BaseSizer, + value: unknown + ) => void, + + } + interface IAddInputConfig { bindingTarget?: Object, bindingKey?: string, autoUpdate?: boolean, - view?: 'string' | 'textarea' | 'number' | 'range' | 'list' | 'buttons' | 'boolean' | 'color' | - ((scene: Phaser.Scene, config: Object, style: Object) => Phaser.GameObjects.GameObject), + view?: string, icon?: string, iconFrame?: string, @@ -135,8 +164,10 @@ declare namespace Tweaker { orientation?: Sizer.OrientationTypes, + // range min?: number, max?: number, + // list, buttons options?: { text: string, value: any @@ -200,13 +231,20 @@ declare class Tweaker extends Sizer { config?: Tweaker.IConfig ); + registerInputHandler( + config: Tweaker.IInputHandlerConfig + ): this; + + removeInputHandler( + name: string + ): this; + addInput( object: Object, key: string, config?: Tweaker.IAddInputConfig ): this; - addInput( config?: Tweaker.IAddInputConfig ): this;